Skip to content

Commit 893d30e

Browse files
bug #53667 [Mailer] [Mailgun] Fix sender header encoding (spajxo)
This PR was submitted for the 6.4 branch but it was squashed and merged into the 6.3 branch instead. Discussion ---------- [Mailer] [Mailgun] Fix sender header encoding | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #51773 (comment) | License | MIT This adjustment fixes a problem with header encoding in MailgunApiTransport. The issue occurs only in some cases when using Sender Address with name part with diacritics, because of the difference in encoding of UnstructuredHeader and MailboxHeader. It changes the method used to add header `h:Sender` so that MailboxHeader is used. Commits ------- 0f3b2f7 [Mailer] [Mailgun] Fix sender header encoding
2 parents 29a5f21 + 0f3b2f7 commit 893d30e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunApiTransportTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,17 @@ public function testTagAndMetadataHeaders()
270270
$this->assertArrayHasKey('v:Client-ID', $payload);
271271
$this->assertSame('12345', $payload['v:Client-ID']);
272272
}
273+
274+
public function testEnvelopeSenderHeaderIsCorrectlyEncoded()
275+
{
276+
$email = new Email();
277+
$envelope = new Envelope(new Address('alice@system.com', 'Žluťoučký Kůň'), [new Address('bob@system.com')]);
278+
279+
$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
280+
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
281+
$payload = $method->invoke($transport, $email, $envelope);
282+
283+
$this->assertArrayHasKey('h:Sender', $payload);
284+
$this->assertSame('=?utf-8?Q?=C5=BDlu=C5=A5ou=C4=8Dk=C3=BD_K=C5=AF=C5=88?= <alice@system.com>', $payload['h:Sender']);
285+
}
273286
}

src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
8787
private function getPayload(Email $email, Envelope $envelope): array
8888
{
8989
$headers = $email->getHeaders();
90-
$headers->addHeader('h:Sender', $envelope->getSender()->toString());
90+
$headers->addMailboxHeader('h:Sender', $envelope->getSender());
9191
$html = $email->getHtmlBody();
9292
if (null !== $html && \is_resource($html)) {
9393
if (stream_get_meta_data($html)['seekable'] ?? false) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy