Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mailer] BCC doesn't work with AWS SES #36333

Closed
Pixelshaped opened this issue Apr 3, 2020 · 10 comments
Closed

[Mailer] BCC doesn't work with AWS SES #36333

Pixelshaped opened this issue Apr 3, 2020 · 10 comments

Comments

@Pixelshaped
Copy link

Pixelshaped commented Apr 3, 2020

Symfony version(s) affected: 4.4.7

Description
I was able to send emails to the to() address, but bcc() seems ignored.
Using templated emails.
The URL I use for the DSN is one of type:
MAILER_DSN=ses://ACCESS_KEY:SECRET_KEY@default?region=eu-west-1

How to reproduce

$email = (new TemplatedEmail())
            ->from(new Address('emailFROM@email.com', 'nameFROM'))
            ->to(new Address('emailTO@email.com', 'nameTO'))
            ->bcc(new Address('emailBCC@email.com', 'nameBCC'))
            ->subject($subject)
            ->htmlTemplate($template)
            ->context($context);

$mailer->send($email);

Nothing more than that. Upon debugging, it seems that when the message is converted to raw the bcc is not present in the headers.

@FlaverSaver
Copy link

The same problem also occurs with SendmailTransport. The cause can be found here: https://github.com/symfony/mime/blob/2aad3728327b3b1fd8137004528129673dec1e09/Message.php#L96
The BCC is removed in all cases.

@xabbuh xabbuh added the Mailer label Apr 6, 2020
@Pixelshaped
Copy link
Author

The same problem also occurs with SendmailTransport. The cause can be found here: https://github.com/symfony/mime/blob/2aad3728327b3b1fd8137004528129673dec1e09/Message.php#L96
The BCC is removed in all cases.

The commentary really makes it look like it's a voluntary omission. Is there any other way to add BCCs ? The issue made me double my API calls (not a big deal in my case but still)

@hyde1
Copy link

hyde1 commented Apr 19, 2020

Hello, same problem here.
SesApiTransport is reading recipients from the Enveloppe when sending messages without attachement.
But SesHttpTransport and SesApiTransport with not attachement are both sending the raw message and without reading the Enveloppe, where all recipients are present...
I think it should use the Destination parameter of the SendRawEmail action by reading the Eveloppe recipients before sending the request.

@akondas
Copy link
Contributor

akondas commented Jun 5, 2020

The problem is with AbstractHttpTransport which uses SentMessage class to send e-mail. All comes down to one method: Symfony\Component\Mime\Message::getPreparedHeaders

        // remove the Bcc field which should NOT be part of the sent message
        $headers->remove('Bcc');

This should be changed to use Email class like AbstractApiTransport, I could fix it, but I don't know if we can do it this way 🤔, maybe I will suggest PR to show you what I mean?

@joey-bolts
Copy link

Same issue here, all Bcc's are removed and not send. Any status update?

@fabpot
Copy link
Member

fabpot commented Oct 6, 2020

I'm not using AWS SES, so someone needs to investigate this issue and submit a patch to fix it. I will then more than happy to review it and merge it.

@frans-beech-it
Copy link

Did some more digging.

The BCC is removed from the header in general for all transports here https://github.com/ehymel/symfony/blob/35b7e1cb9a9c3fafe0c68386fae13721ea05aa82/src/Symfony/Component/Mime/Message.php#L99

But when using sendmail the bcc header is needed and stripped by sendmail for instance.

If we look at the swiftmail implementation you see BCC is only removed for SMTP see https://github.com/swiftmailer/swiftmailer/blob/59935da5e9d4c7ae801bb393d638dac2515498c9/lib/classes/Swift/Transport/AbstractSmtpTransport.php#L203

@fabpot would that also be a proper solution for symfony/mailer?

@jderusse
Copy link
Member

jderusse commented Jan 6, 2021

SES issue will be fixed by #39743 You can use ses+api as a workaround. Or bump to symfony 5.2 + install async-aws/ses

@jderusse
Copy link
Member

jderusse commented Jan 6, 2021

Regarding the sendmail issue, could somebody test this PR #39744 ?

/cc @frans-beech-it

nicolas-grekas added a commit that referenced this issue Jan 12, 2021
This PR was merged into the 4.4 branch.

Discussion
----------

[Mailer] Fix missing BCC recipients in SES bridge

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36333
| License       | MIT
| Doc PR        | -

When using the `ses` (alias of `ses+https`) scheme, the bridge send the RawEmail to AWS.
But RawEmails does not contains the BCC recipients.

This PR adds the envelope's recipients to the list of Destinations in Amazon SES payload.

Commits
-------

1cfc763 Fix missing BCC recipients in SES bridge
@frans-beech-it
Copy link

@nicolas-grekas @jderusse should we create a new issue for the sendmail transport issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests