1. Answers
  2. Configuring Custom MAIL FROM domain for SES email sending

How do I configure a custom MAIL FROM domain for SES email sending?

In this guide, we will configure a custom MAIL FROM domain for Amazon Simple Email Service (SES) to ensure that your emails are properly authenticated and pass SPF checks. This involves creating SES domain identity, verifying the domain, and setting up the MAIL FROM domain.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Define the domain and MAIL FROM domain
const domain = "example.com";
const mailFromDomain = `mail.${domain}`;

// Create an SES Domain Identity
const domainIdentity = new aws.ses.DomainIdentity("domainIdentity", {
    domain: domain,
});

// Create an SES Mail From resource
const mailFrom = new aws.ses.MailFrom("mailFrom", {
    domain: domain,
    mailFromDomain: mailFromDomain,
    behaviorOnMxFailure: "UseDefaultValue", // Use default MAIL FROM domain if MX lookup fails
});

// Output the domain identity verification token
export const verificationToken = domainIdentity.verificationToken;

// Output the MAIL FROM domain
export const outputMailFromDomain = mailFrom.mailFromDomain;

Key Points

  • SES Domain Identity: This resource represents the domain you want to verify with SES.
  • SES Mail From: This resource sets up the custom MAIL FROM domain and specifies the behavior if the required MX record can’t be found.
  • Verification Token: This token is used to verify the domain ownership.

Summary

We have configured a custom MAIL FROM domain for SES email sending. This setup includes creating an SES domain identity, setting up the MAIL FROM domain, and handling MX lookup failures. The verification token is also provided for domain verification purposes.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up