I am sending a mail through ses in nodejs.
exports.sendEmail = async () => {
const SESConfig = {
accessKeyId: "xxxxxxx",
accessSecretKey: "xxxxxxxxxxxxxx",
region: "us-east-1",
}
AWS.config.update(SESConfig);
// Create sendEmail params
var params = {
Destination: {
ToAddresses: [
"xxx@xxx.xxx",
/* more items */
],
},
Message: {
/* required */
Body: { Text: {
Charset: "UTF-8",
Data: "TEXT_FORMAT_BODY",
},
},
Subject: {
Charset: "UTF-8",
Data: "Test email",
},
},
Source: "xxx@xxx.xxx" /* required */,
};
var sendPromise = new AWS.SES({ apiVersion: "2010-12-01" })
.sendEmail(params)
.promise();
// Handle promise's fulfilled/rejected states
await sendPromise
.then(function (data) {
console.log('err', data)
console.log(data.MessageId);
})
.catch(function (err) {
console.log('err', err)
console.error(err, err.stack);
});
};
When i call this function in my api then it's saying Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 I had added same mail in from and to which is verified on aws ses