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] Add Bcc recipients to sendmail #39744

Open
wants to merge 1 commit into
base: 4.4
from

Conversation

@jderusse
Copy link
Member

@jderusse jderusse commented Jan 6, 2021

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

When sending an email via sendmail with flag -t, Symfony will send a raw email, and the sendmail binary will get the recipient list from the message headers. But the BCC header is not removed from the RawEmail on purpose.

This PR injects the removed BCC headers.

@carsonbot carsonbot added this to the 4.4 milestone Jan 6, 2021
}
} else {
foreach ($message->getEnvelope()->getRecipients() as $recipient) {
$this->stream->write('Bcc:'.$recipient->toString()."\n");

This comment has been minimized.

@jderusse

jderusse Jan 6, 2021
Author Member

I'm not sure this is a good idea.

Basically, if somebody send an email to foo, the payload sent to sendmail will contain to: foo and Bcc: foo...

Do you have a better idea to find the missing recipients?...

This comment has been minimized.

@frans-beech-it

frans-beech-it Jan 7, 2021

the Bcc should always be in the $message->getOriginalMessage()->message so maybe walk through $message->getOriginalMessage()->toIterable() until you get the Content-Type header?

But feels hacky 😬

$email = $message->getOriginalMessage();
if ($email instanceof Email) {
foreach ($email->getBcc() as $recipient) {
$this->stream->write('Bcc:'.$recipient->toString()."\n");

This comment has been minimized.

@jderusse

jderusse Jan 6, 2021
Author Member

Is it allowed to send Bcc: header BEFORE the rest of the payload?

This comment has been minimized.

@frans-beech-it

frans-beech-it Jan 7, 2021

header now starts with From: and as Bcc: is part of the destination fields I don't think that should be a problem https://tools.ietf.org/html/rfc2822#section-3.6.3

But my main concern is that you "fix" this now on this place. But as Bcc is part of the official RFC for defining mails why is is not just part of the header of the message? And removed on the place where i'ts processed as described in the RFC?

So remove

$headers->remove('Bcc');
and adjust the transports that handle the recipients self like smtp

This comment has been minimized.

@jderusse

jderusse Jan 7, 2021
Author Member

Sendmail and Smtp (and many other transports) send the exact same payload. Reverting this change will affect everybody, it would be BC break, and maybe a security issue.

The question is. Should we re-add the Bcc header for transport that support it?
Or should we remove the Bcc header for transports that does not support it?

In my opinion, the option 1 (the one Symfony is currently using) is safe by default and we should keep that behavior.
Some transports (like Smtp, Sqs) provides alternatives ways to inject the recipients without sending this header.

This comment has been minimized.

@frans-beech-it

frans-beech-it Jan 7, 2021

I get the BC issue. But currently the Mime/Message.php output is just not following the email specifications 😬

And yes the order transports handle this currently on there own. But IMO the code should try to be as close to the specifications to keep it understandable for others.

The other only "save" way to fix this for the sendMailTransport is to grep the raw message and search for the bcc header but not sure if that will be robust enough.

But adding every recipient as Bcc is not a real solution IMHO

@jderusse jderusse force-pushed the jderusse:sendmail-bcc branch from f188438 to f34ae6b Jan 7, 2021
@derrabus derrabus added the Mailer label Jan 8, 2021
@carsonbot carsonbot changed the title Add Bcc recipients to sendmail [Mailer] Add Bcc recipients to sendmail Jan 8, 2021
@Toflar
Copy link
Contributor

@Toflar Toflar commented Mar 22, 2021

Any status update on this? I've just debugged my app and found out that BCC is completely ignored when using sendmail. It even happens silently so nobody even notices it.

@dsuurlant
Copy link

@dsuurlant dsuurlant commented Apr 9, 2021

I second @Toflar 's comment, this took a lot of debugging to figure out that Symfony Mailer is just discarding Bcc recipients.

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

Successfully merging this pull request may close these issues.

None yet

6 participants