Skip to content

Support custom MAIL FROM domain for SES#6906

Merged
vimtor merged 3 commits into
anomalyco:devfrom
nabla-studio:giorgionocera/feat-add_mailfrom_Email
Jun 24, 2026
Merged

Support custom MAIL FROM domain for SES#6906
vimtor merged 3 commits into
anomalyco:devfrom
nabla-studio:giorgionocera/feat-add_mailfrom_Email

Conversation

@giorgionocera

Copy link
Copy Markdown
Contributor

Description

Adds support for configuring a custom MAIL FROM domain on the aws.Email component.

By default, SES sets the Return-Path (envelope sender) to amazonses.com. Setting a custom MAIL FROM subdomain of your own sender domain:

  • Improves SPF alignment for DMARC;
  • Routes bounce and complaint feedback through your own domain.

Usage

new sst.aws.Email("MyEmail", {
  sender: "example.com",
  mailFrom: {
    domain: "mail.example.com",
  },
});

What's included

  • New mailFrom arg with domain and optional rejectOnMxFailure (maps to SES behaviorOnMxFailure: REJECT_MESSAGE vs USE_DEFAULT_VALUE);
  • Creates the sesv2.EmailIdentityMailFromAttributes resource (whitelisted in component.ts);
  • Automatically provisions the required MX (feedback-smtp.<region>.amazonses.com looked up via getRegionOutput) and SPF/TXT (v=spf1 include:amazonses.com ~all) DNS records;
  • Validation: mailFrom is only valid when sender is a domain, and mailFrom.domain must be a subdomain of sender;
  • Adds transform.mailFromAttributes to customize the underlying resource.

Supporting changes

Adds a priority field to the shared DNS Record interface (applies to MX records). It is needed so the MAIL FROM MX record can set priority 10, as suggested in the AWS docs; Each DNS provider encodes priority differently, so it's threaded through accordingly:

  • AWS (Route53): priority is prepended into the record value string ("10 feedback-smtp.<region>.amazonses.com"), not a separate field;
  • Cloudflare: passed as a separate priority field on the record;
  • Vercel: passed as mxPriority, which required adding the field to the custom Go dynamic provider (pkg/server/resource/vercel-dns-record.go) in addition to the TS provider omitempty drops it for non-MX records.

Also adds a new examples/aws-email-domain example app demonstrating the feature.

Testing

Deployed the aws-email-domain example end-to-end against all three DNS providers (AWS Route53, Cloudflare, and Vercel) and confirmed for each that:

  • The MX (feedback-smtp..amazonses.com, priority 10) and TXT records are created correctly, with priority encoded the right way per provider;
  • The MAIL FROM domain shows as verified in the SES console;
  • A test email actually sent through the identity arrives with the Return-Path / MAIL FROM set to the custom domain (not amazonses.com).

Closes #6905

Adding support for priority property on DNS records (for MX records).
Adding suport for custom MAIL_FROM in Email component.
Adding an example where email sender is managed through domain (instead of email address).
@vimtor vimtor changed the title feat(aws/Email): support custom MAIL FROM domain for SES Support custom MAIL FROM domain for SES Jun 24, 2026
@vimtor vimtor merged commit 9321c40 into anomalyco:dev Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email: support custom MAIL FROM domain for SES (SPF alignment)

2 participants