Skip to content

Prepend X-Original-To when the message body is stored in S3 - #11

Open
jesusch wants to merge 2 commits into
aws:mainfrom
jesusch:fix-s3-envelope-recipient
Open

jesusch wants to merge 2 commits into
aws:mainfrom
jesusch:fix-s3-envelope-recipient

Conversation

@jesusch

@jesusch jesusch commented Sep 30, 2026

Copy link
Copy Markdown

Issue #, if available:

Description of changes:

SNSNotification#message_content prepends X-Original-To from the first SES envelope recipient when the message is inline in the SNS payload. When the receipt action is S3, it returned the object bytes with no header.

Action Mailbox apps (Chatwoot included) match the inbox on To, Cc, or X-Original-To. Group and BCC copies often have the inbox address only in mail.destination. Those messages were stored and then discarded.

Both paths now use the same prefix. The S3 request spec expects the stored raw email to start with that header.

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

Test plan

  • message_content on the S3 fixture returns X-Original-To: recipient@example.com plus the object body
  • Mail parses that header from the prepended string
  • CI request spec receives an inbound email with data in s3 (local Ruby 4 + json 3 cannot encode the request; quirks_mode is raised by the test client before the app runs)

Made with Cursor

The inline path already did this from the first envelope recipient. The S3 path returned the object unchanged, so apps that route on that header dropped mail whose inbox address was only on the SMTP envelope.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jesusch
jesusch requested a review from a team as a code owner September 30, 2026 10:07
mail.destination is the visible To and Cc. A BCC whose inbox address is only the envelope recipient was labeled with the To header, so routing missed the inbox.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant