Reputation: 6002
I am sending Emails via the aws-sdk
for Nodejs like this:
const params = {
Destination: {
ToAddresses: [... ],
},
Message: {
Body: {
Html: {
Data: `...`,
Charset: 'utf-8'
},
},
Subject: {
Data: `...`,
Charset: 'utf-8'
}
},
Source: '[email protected]',
ReturnPath: '[email protected]',
};
awsConfig.ses.sendEmail(params, (err, data))
The received email looks like this in Gmail:
However, I want to know how to change this name:
Currently the from name is support
, because the from email is [email protected]
. But I want it to be replaced by the company like GitHub
below.
Thanks in advance for any help!
Upvotes: 6
Views: 2534
Reputation: 6002
Here is what I ended up doing:
I set the Source
attribute in the params to
'CompanyName <[email protected]>'
Thanks to @Neil Lunn
Upvotes: 11
Reputation: 140
You can use this syntax
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create sendEmail params
var params = {
Destination: { /* required */
CcAddresses: [
'EMAIL_ADDRESS',
/* more items */
],
ToAddresses: [
'EMAIL_ADDRESS',
/* more items */
]
},
Message: { /* required */
Body: { /* required */
Html: {
Charset: "UTF-8",
Data: "HTML_FORMAT_BODY"
},
Text: {
Charset: "UTF-8",
Data: "TEXT_FORMAT_BODY"
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Test email'
}
},
Source: 'SENDER_EMAIL_ADDRESS', /* required */
ReplyToAddresses: [
'EMAIL_ADDRESS',
/* more items */
],
};
// Create the promise and SES service object
var sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();
// Handle promise's fulfilled/rejected states
sendPromise.then(
function(data) {
console.log(data.MessageId);
}).catch(
function(err) {
console.error(err, err.stack);
});
Upvotes: -1