amazon-web-servicesamazon-ses

How can I send using the default FROM address with AWS SDK (JavaScript) v3 for SES?


How can I specify the Source to be the default MAIL FROM address (no-reply@amazonses.com or similar) with AWS SDK (JavaScript) v3 for SES?

The official documentation says this is possible, but does not state how to specify it:

Messages that you send through Amazon SES automatically use a subdomain of amazonses.com as the default MAIL FROM domain. Sender Policy Framework (SPF) authentication successfully validates these messages because the default MAIL FROM domain matches the application that sent the email—in this case, SES.

I have tried:

Snippet from official example:

import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses"; // ES Modules import

const client = new SESClient();

// The following example sends a formatted email:
const input = {
  Destination: {
    BccAddresses:     [],
    CcAddresses: [
      "recipient3@example.com"
    ],
    ToAddresses: [
      "recipient1@example.com",
      "recipient2@example.com"
    ]
  },
  Message: {
    Body: {
      Html: {
        Charset: "UTF-8",
        Data: `This message body contains HTML formatting. It can, for example, contain links like this one: <a class="ulink" href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide" target="_blank">Amazon SES Developer Guide</a>.`
      },
      Text: {
        Charset: "UTF-8",
        Data: "This is the message body in text format."
      }
    },
    Subject: {
      Charset: "UTF-8",
      Data: "Test email"
    }
  },
  ReplyToAddresses:   [],
  ReturnPath: "",
  ReturnPathArn: "",
  // Source: undefined, // ValidationError
  // Source: "", // InvalidParameterValue
  // Source: "no-reply@amazonses.com", // MessageRejected: Email address is not verified. The following identities failed the check in region
  SourceArn: ""
};
const command = new SendEmailCommand(input);
const response = await client.send(command);

Solution

  • You are confusing the FROM address and the MAIL FROM address. If you read the first paragraph on the page you linked, you can see that they are two separate things:

    When an email is sent, it has two addresses that indicate its source: a From address that's displayed to the message recipient, and a MAIL FROM address that indicates where the message originated. The MAIL FROM address is sometimes called the envelope sender, envelope from, bounce address, or Return Path address. Mail servers use the MAIL FROM address to return bounce messages and other error notifications. The MAIL FROM address is usually only viewable by recipients if they view the source code for the message.

    There is no such thing as a default FROM address in SES. You absolutely have to specify a FROM address when you are sending the email.

    The MAIL FROM domain is something that basically indicates what mail server the mail came from, and SES will set a default value there letting the receiver know it came from Amazon SES unless you setup a custom MAIL FROM domain, as detailed on the documentation page you linked.