[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.
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.
Hmm yeah ok i'll add those checks back in, with the specific headers
There was a problem hiding this comment.
BCC won't be in the string (but this is tested by checking the list of recipients)
There was a problem hiding this comment.
@driesvints Specifically checking for these headers now 👍 Confirmed that the BCC address is normally returned with $sentMessage->getEnvelope()->getRecipients()
|
|
||
| $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.
Added this for extra measure
When using
Mail::alwaysToin 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
alwaysTobeing set, an attempt to send an email with To, Cc, Bcc and the resultant email with the added headers.