ConfigError: Missing region in config when i am using amazon ses with Node.js
ConfigError: Missing region in config when i am using amazon ses with Node.js
我使用了一个 env 文件,我使用了这样的结构并收到此错误如何解决
"AWS_SES_REGION":"us-east-1" and i have put us-west-2 also but still getting the same error
"AWS_ACCESS_KEY_ID":"value"
"AWS_SECRET_KEY":"value"
这是我用来发送电子邮件的代码 谁能建议我如何解决这个问题
require('dotenv').config();
const AWS = require('aws-sdk');
const SESConfig = {
apiVersion:"2010-12-01",
accessKeyId:process.env.AWS_SECRET_KEY,
accessSecretKey:process.env.AWS_SECRET_KEY,
region:process.env.AWS_SES_REGION
}
// AWS.SESConfig.update({region: 'eu-central-1'});
var params = {
Source: 'xyz045@gmail.com',
Destination: {
ToAddresses: [
'yyy45@gmail.com'
]
},
ReplyToAddresses: [
'xyz05@gmail.com',
],
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: 'IT IS <strong>WORKING</strong>!'
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Node + SES Example'
}
}
};
new AWS.SES(SESConfig).sendEmail(params).promise().then((res) => {
console.log(res);
}).catch(error => {
console.log(error)
});
尝试使用 AWS.Config
class 加载配置。
示例:
require('dotenv').config();
const AWS = require('aws-sdk');
const SESConfig = {
apiVersion: "2010-12-01",
accessKeyId: process.env.AWS_SECRET_KEY,
accessSecretKey: process.env.AWS_SECRET_KEY,
region: process.env.AWS_SES_REGION
}
let config = new AWS.Config(SESConfig); // Load the configuration like this.
/*
Or you could update the config like this.
AWS.config.update(SESConfig);
*/
var params = {
Source: 'xyz045@gmail.com',
Destination: {
ToAddresses: [
'yyy45@gmail.com'
]
},
ReplyToAddresses: [
'xyz05@gmail.com',
],
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: 'IT IS <strong>WORKING</strong>!'
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Node + SES Example'
}
}
};
new AWS.SES().sendEmail(params).promise().then((res) => {
console.log(res);
}).catch(error => {
console.log(error)
});
我使用了一个 env 文件,我使用了这样的结构并收到此错误如何解决
"AWS_SES_REGION":"us-east-1" and i have put us-west-2 also but still getting the same error
"AWS_ACCESS_KEY_ID":"value"
"AWS_SECRET_KEY":"value"
这是我用来发送电子邮件的代码 谁能建议我如何解决这个问题
require('dotenv').config();
const AWS = require('aws-sdk');
const SESConfig = {
apiVersion:"2010-12-01",
accessKeyId:process.env.AWS_SECRET_KEY,
accessSecretKey:process.env.AWS_SECRET_KEY,
region:process.env.AWS_SES_REGION
}
// AWS.SESConfig.update({region: 'eu-central-1'});
var params = {
Source: 'xyz045@gmail.com',
Destination: {
ToAddresses: [
'yyy45@gmail.com'
]
},
ReplyToAddresses: [
'xyz05@gmail.com',
],
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: 'IT IS <strong>WORKING</strong>!'
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Node + SES Example'
}
}
};
new AWS.SES(SESConfig).sendEmail(params).promise().then((res) => {
console.log(res);
}).catch(error => {
console.log(error)
});
尝试使用 AWS.Config
class 加载配置。
示例:
require('dotenv').config();
const AWS = require('aws-sdk');
const SESConfig = {
apiVersion: "2010-12-01",
accessKeyId: process.env.AWS_SECRET_KEY,
accessSecretKey: process.env.AWS_SECRET_KEY,
region: process.env.AWS_SES_REGION
}
let config = new AWS.Config(SESConfig); // Load the configuration like this.
/*
Or you could update the config like this.
AWS.config.update(SESConfig);
*/
var params = {
Source: 'xyz045@gmail.com',
Destination: {
ToAddresses: [
'yyy45@gmail.com'
]
},
ReplyToAddresses: [
'xyz05@gmail.com',
],
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: 'IT IS <strong>WORKING</strong>!'
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Node + SES Example'
}
}
};
new AWS.SES().sendEmail(params).promise().then((res) => {
console.log(res);
}).catch(error => {
console.log(error)
});