Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 69c1bdb

Browse filesBrowse files
everyxfabpot
authored andcommitted
fix: stringify from address for ses+api transport
close: #45660
1 parent d63e0fe commit 69c1bdb
Copy full SHA for 69c1bdb

File tree

Expand file treeCollapse file tree

2 files changed

+17
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-12
lines changed

‎src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function testSend()
8282
$this->assertSame('Hello!', $content['Content']['Simple']['Subject']['Data']);
8383
$this->assertSame('"Saif Eddin" <saif.gmati@symfony.com>', $content['Destination']['ToAddresses'][0]);
8484
$this->assertSame('=?UTF-8?B?SsOpcsOpbXk=?= <jeremy@derusse.com>', $content['Destination']['CcAddresses'][0]);
85-
$this->assertSame('"Fabien" <fabpot@symfony.com>', $content['FromEmailAddress']);
85+
$this->assertSame('=?UTF-8?B?RmFiacOpbg==?= <fabpot@symfony.com>', $content['FromEmailAddress']);
8686
$this->assertSame('Hello There!', $content['Content']['Simple']['Body']['Text']['Data']);
8787
$this->assertSame('<b>Hello There!</b>', $content['Content']['Simple']['Body']['Html']['Data']);
8888
$this->assertSame(['replyto-1@example.com', 'replyto-2@example.com'], $content['ReplyToAddresses']);
@@ -103,7 +103,7 @@ public function testSend()
103103
$mail->subject('Hello!')
104104
->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
105105
->cc(new Address('jeremy@derusse.com', 'Jérémy'))
106-
->from(new Address('fabpot@symfony.com', 'Fabien'))
106+
->from(new Address('fabpot@symfony.com', 'Fabién'))
107107
->text('Hello There!')
108108
->html('<b>Hello There!</b>')
109109
->replyTo(new Address('replyto-1@example.com'), new Address('replyto-2@example.com'))

‎src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesApiAsyncAwsTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesApiAsyncAwsTransport.php
+15-10Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function getRequest(SentMessage $message): SendEmailRequest
5353
$envelope = $message->getEnvelope();
5454

5555
$request = [
56-
'FromEmailAddress' => $envelope->getSender()->toString(),
56+
'FromEmailAddress' => $this->stringifyAddress($envelope->getSender()),
5757
'Destination' => [
5858
'ToAddresses' => $this->stringifyAddresses($this->getRecipients($email, $envelope)),
5959
],
@@ -114,15 +114,20 @@ private function getRecipients(Email $email, Envelope $envelope): array
114114
protected function stringifyAddresses(array $addresses): array
115115
{
116116
return array_map(function (Address $a) {
117-
// AWS does not support UTF-8 address
118-
if (preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $name = $a->getName())) {
119-
return sprintf('=?UTF-8?B?%s?= <%s>',
120-
base64_encode($name),
121-
$a->getEncodedAddress()
122-
);
123-
}
124-
125-
return $a->toString();
117+
return $this->stringifyAddress($a);
126118
}, $addresses);
127119
}
120+
121+
protected function stringifyAddress(Address $a): string
122+
{
123+
// AWS does not support UTF-8 address
124+
if (preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $name = $a->getName())) {
125+
return sprintf('=?UTF-8?B?%s?= <%s>',
126+
base64_encode($name),
127+
$a->getEncodedAddress()
128+
);
129+
}
130+
131+
return $a->toString();
132+
}
128133
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.