10000 [Mailer] [Mailgun] Fix sender header encoding by spajxo · Pull Request #53667 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mailer] [Mailgun] Fix sender header encoding #53667

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

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Mailer] [Mailgun] Fix sender header encoding
  • Loading branch information
spajxo authored and nicolas-grekas committed Jan 29, 2024
commit 0f3b2f79fdfa4d60df5b9f843243f4dd59dafe15
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,17 @@ public function testTagAndMetadataHeaders()
$this->assertArrayHasKey('v:Client-ID', $payload);
$this->assertSame('12345', $payload['v:Client-ID']);
}

public function testEnvelopeSenderHeaderIsCorrectlyEncoded()
{
$email = new Email();
$envelope = new Envelope(new Address('alice@system.com', 'Žluťoučký Kůň'), [new Address('bob@system.com')]);

$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
$payload = $method->invoke($transport, $email, $envelope);

$this->assertArrayHasKey('h:Sender', $payload);
$this->assertSame('=?utf-8?Q?=C5=BDlu=C5=A5ou=C4=8Dk=C3=BD_K=C5=AF=C5=88?= <alice@system.com>', $payload['h:Sender']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
private function getPayload(Email $email, Envelope $envelope): array
{
$headers = $email->getHeaders();
$headers->addHeader('h:Sender', $envelope->getSender()->toString());
$headers->addMailboxHeader('h:Sender', $envelope->getSender());
$html = $email->getHtmlBody();
if (null !== $html && \is_resource($html)) {
if (stream_get_meta_data($html)['seekable'] ?? false) {
Expand Down
0