-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[9.x] Add X
headers when using Mail::alwaysTo
#41101
Conversation
$this->assertStringContainsString('X-Cc: dries@laravel.com', $sentMessage->toString()); | ||
$this->assertStringContainsString('X-Bcc: james@laravel.com', $sentMessage->toString()); | ||
$this->assertFalse($recipients->contains('nuno@laravel.com')); | ||
$this->assertFalse($recipients->contains('dries@laravel.com')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be a bit carefully here because we're not actually checking anymore if the CC: and BCC: headers are not present anymore (something the original tests implicitly did). I don't think BCC recipients, for example, are listed in the recipients of an envelope to begin with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah ok i'll add those checks back in, with the specific headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BCC won't be in the string (but this is tested by checking the list of recipients)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driesvints Specifically checking for these headers now 👍 Confirmed that the BCC address is normally returned with $sentMessage->getEnvelope()->getRecipients()
@@ -200,6 +200,7 @@ public function testGlobalToIsRespectedOnAllMessages() | |||
|
|||
$sentMessage = $mailer->send('foo', ['data'], function (Message $message) { | |||
$message->from('hello@laravel.com'); | |||
$message->to('nuno@laravel.com'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this for extra measure
When using
Mail::alwaysTo
in development environments, the original To, Cc and Bcc are lost. This makes it difficult to determine where the email was going to during testing.This PR adds the original to, cc and bcc into X-Headers in the email so this information can be retrieved, while still preventing the email being sent to these recipients.
The below screenshot of Helo shows
alwaysTo
being set, an attempt to send an email with To, Cc, Bcc and the resultant email with the added headers.