[13.x] Add SES tenant support to the SES v2 transport#60886
Open
atymic wants to merge 1 commit into
Open
Conversation
Author
|
Test failures seem unrelated, all email tests pass for me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Amazon SES tenants let you isolate sending into separate containers, each with its own reputation metrics, reputation policy and suppression list. If one tenant's sending goes bad, SES pauses that tenant instead of the whole account. Useful if you send on behalf of a lot of downstream customers.
To send as a tenant you pass
TenantNametoSendEmail. The AWS SDK has supported this since 3.352.0, but there's no way to set it per message right now.SesV2Transportoptions are transport level, so a singlesesmailer can't vary the tenant between messages.This adds an
X-SES-TENANT-NAMEheader that the transport turns into theTenantNameparameter, same as the existingX-SES-LIST-MANAGEMENT-OPTIONSheader does.From a mailable:
Or a notification:
If the header isn't set,
TenantNameisn't passed and nothing changes.Older SDK versions
Laravel requires
aws/aws-sdk-php^3.322.9, andTenantNameonly landed in 3.352.0, so I tested against 3.351.0 to check what happens on an SDK that predates it. It's safe: the SDK builds requests from its bundled API model, so an unknown key doesn't hit validation and is just left out of the request body. Nothing throws, the mail still sends, it just sends without a tenant.I didn't bump the constraint, since that would push every SQS/DynamoDB/SES user onto a newer SDK for one optional SES feature. Happy to add a runtime exception when the installed SDK is too old if you'd prefer it fail loudly rather than silently ignore the header, just left it out for now to keep this small.
Notes
Setting the tenant in the
optionsarray inconfig/mail.phpalready works if you only have one tenant, so this is just for varying it per message.The header stays on the outgoing message, which is the same as
X-Metadata-*andX-SES-LIST-MANAGEMENT-OPTIONStoday. Transports can't strip headers becauseSentMessagecaptures the raw MIME beforedoSend()runs.I've used
X-SES-TENANT-NAMEto match the API parameter and the otherX-SES-*headers, but SES usesX-SES-TENANTfor its SMTP integration. Happy to rename it if you'd prefer to match that.