Description
Symfony version(s) affected: 4.4/5.0
Description
The AWS SES API transport implementation for Mailer is not using the recipients set on the envelope in all cases. If an email has attachments the envelope is entirely ignored and the message send in its raw form. In every other case "to" destination is set from the envelope but cc and bcc is still read from the email headers.
How to reproduce
Configure the Mailer with AWS API transport (ses+api://AWS_ACCESS_KEY_ID: AWS_SECRET_ACCESS_KEY@default), override the recipients via EnvelopeListener according to the sf docs and send an email with attachment (envelope ignored) or a cc/bcc (to gets rewritten but cc/bcc is still delivered).
Possible Solution
Use the AWS SES SendRawEmail endpoint in any case and set the API parameter Destinations
to override an emails recipient in case the envelop recipient are different from the emails header recipients.
Additional context
For us this is kind of critical because we use redirection in a staging environment where the customer is expecting all emails to be redirected while testing his software. We are currently using our own AWS Mailer transport based on the AWS SDK and implemented the mentioned fix and redirects are done reliable. I would be happy to provide a PR with an implementation for the Symfony provided transport.