Skip to content

Keep the sender's display name with the SES transport - #791

Merged
taylorotwell merged 2 commits into
laravel:0.xfrom
chrisreedio:fix/ses-sender-display-name
Dec 3, 2026
Merged

taylorotwell merged 2 commits into
laravel:0.xfrom
chrisreedio:fix/ses-sender-display-name

Conversation

@chrisreedio

@chrisreedio chrisreedio commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Emails sent with the ses transport lose the sender's display name. With [email protected] and MAIL_FROM_NAME=Example, recipients see [email protected] rather than Example <[email protected]>. A per-message Message::from((address, name)) loses its name the same way. The resend transport keeps it.

Why

SesTransport sends raw MIME, and Email::to_mime writes the correct header: From: "Example" <[email protected]>. The transport also sets SES v2 SendEmail's FromEmailAddress to the bare address, and for raw content SES v2 lets FromEmailAddress replace the message's From header. (SES v1's SendRawEmail preferred the header over Source; nodemailer#1430 ran into the same difference.)

FromEmailAddress is optional for raw content. Without it, SES takes the sender from the From header. The transport doesn't use sending authorization, the one case where it's needed.

How we verified it

We sent one raw message, whose header was From: "Example" <[email protected]>, through SES v2 twice from a verified domain to an inbox we could read. The only difference between the two sends was FromEmailAddress:

SendEmail call From header received
With [email protected] (the transport today) From: [email protected]
Without FromEmailAddress (this PR) From: Example <[email protected]>

A production email sent by the transport showed the same bare From, with DKIM passing over it, so the name was gone before it left SES. We now run this change through [patch.crates-io].

Changes

  • crates/notifications/src/mail/ses.rs: stop setting from_email_address.
  • tests/mail.rs: ses_sends_raw_mime_with_every_recipient_in_the_envelope asserted that FromEmailAddress was sent. It now asserts that it isn't, and that the raw From header carries the encoded name (Café Zoë) with the address.

Checks run

  • cargo fmt --all -- --check
  • cargo clippy -p laravel-rust-notifications --all-targets --all-features -- -D warnings
  • cargo test --all-features --test queue ses_: 19 passed. With the ses.rs change reverted, the updated test fails on the FromEmailAddress assertion.

@chrisreedio
chrisreedio force-pushed the fix/ses-sender-display-name branch 2 times, most recently from 96ced93 to f2ef447 Compare December 3, 2026 21:04
SES v2 SendEmail lets FromEmailAddress replace a raw message's From header, so passing the bare address dropped the sender's display name. SES reads the sender from the header, which the message always carries.

Co-authored-by: Chris Reed <[email protected]>
@chrisreedio
chrisreedio force-pushed the fix/ses-sender-display-name branch from f2ef447 to 73e07de Compare December 3, 2026 21:05
@taylorotwell taylorotwell added bug p2 Priority 2: medium labels Dec 3, 2026 — with Amp for GitHub

Copy link
Copy Markdown
Member

This is an automated, agent-powered review.

Confirmed. The ses transport sends raw MIME whose From header carries the sender's name, but it also passes the bare address as SES v2's FromEmailAddress, which SES uses as the message's From. An app with MAIL_MAILER=ses and MAIL_FROM_NAME=Acme sends every email from a bare [email protected] instead of Acme <[email protected]>, and a per-message from((address, name)) loses its name the same way. The updated test fails on 0.x because FromEmailAddress is still sent.

  • The fix is in the right place. Email::to_mime already writes the correct header, and FromEmailAddress is optional for raw content, so leaving it out lets SES read the sender from that header. Passing a formatted mailbox in FromEmailAddress would also work, but it would duplicate the header and its encoded-word handling for names like Café Zoë.
  • If the transport ever supports sending authorization, it will need FromEmailAddress again, and it should then pass the full mailbox rather than the bare address.
  • No breaking changes.

Thanks for your contribution, a human review will follow shortly.

@chrisreedio
chrisreedio marked this pull request as ready for review December 3, 2026 22:35
@taylorotwell
taylorotwell merged commit 0e7f858 into laravel:0.x Dec 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug p2 Priority 2: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants