AG_HIHI
AG_HIHI

Reputation: 1995

AWS-SES: How to set the display name for the sender address

I am using aws-ses for transactional mailing.
And the email address has this format:

noreply@domain_name.com

The problem is that when the users receive their emails, they see that the sender's name is "noreply" but I'd like to change it to something custom and more friendly.

Here's how SES is configured:

const { SESClient, SendEmailCommand } = require("@aws-sdk/client-ses");
const REGION = "us-west-2"; //e.g. "us-east-1"
// Create SES service object.
const sesClient = new SESClient({ region: REGION });

const prepare_params = (destination_address, subject, html_email_content) => {
  // Set the parameters
  const params = {
    Destination: {
      /* required */
      CcAddresses: [
        /* more items */
      ],
      ToAddresses: [
        destination_address, //RECEIVER_ADDRESS
        /* more To-email addresses */
      ],
    },
    Message: {
      /* required */
      Body: {
        /* required */
        Html: {
          Charset: "UTF-8",
          Data: html_email_content,
        },
        Text: {
          Charset: "UTF-8",
          Data: "TEXT_FORMAT_BODY",
        },
      },
      Subject: {
        Charset: "UTF-8",
        Data: subject,
      },
    },
    Source: "noreply@domain_name.com", // SENDER_ADDRESS
    ReplyToAddresses: [
      /* more items */
    ],
  };
  return params;
};
const sendEmail = async (destination_address, subject, html_email_content) => {
  const params = prepare_params(
    destination_address,
    subject,
    html_email_content
  );
  const data = await sesClient.send(new SendEmailCommand(params));
  return data;
};
exports.sendEmail = sendEmail;

Any idea how to solve this?

Upvotes: 21

Views: 7366

Answers (1)

euTIMER
euTIMER

Reputation: 751

try to change

Source: "noreply@domain_name.com", // SENDER_ADDRESS

to (edited)

Source: "Friendly Name <noreply@domain_name.com>", // SENDER_ADDRESS

if this it works let me know!

Upvotes: 39

Related Questions