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

[Mailer] fix: stringify from address for ses+api transport #45691

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
Mar 14, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testSend()
$this->assertSame('Hello!', $content['Content']['Simple']['Subject']['Data']);
$this->assertSame('"Saif Eddin" <saif.gmati@symfony.com>', $content['Destination']['ToAddresses'][0]);
$this->assertSame('=?UTF-8?B?SsOpcsOpbXk=?= <jeremy@derusse.com>', $content['Destination']['CcAddresses'][0]);
$this->assertSame('"Fabien" <fabpot@symfony.com>', $content['FromEmailAddress']);
$this->assertSame('=?UTF-8?B?RmFiacOpbg==?= <fabpot@symfony.com>', $content['FromEmailAddress']);
$this->assertSame('Hello There!', $content['Content']['Simple']['Body']['Text']['Data']);
$this->assertSame('<b>Hello There!</b>', $content['Content']['Simple']['Body']['Html']['Data']);
$this->assertSame(['replyto-1@example.com', 'replyto-2@example.com'], $content['ReplyToAddresses']);
Expand All @@ -103,7 +103,7 @@ public function testSend()
$mail->subject('Hello!')
->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
->cc(new Address('jeremy@derusse.com', 'Jérémy'))
->from(new Address('fabpot@symfony.com', 'Fabien'))
->from(new Address('fabpot@symfony.com', 'Fabién'))
->text('Hello There!')
->html('<b>Hello There!</b>')
->replyTo(new Address('replyto-1@example.com'), new Address('replyto-2@example.com'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getRequest(SentMessage $message): SendEmailRequest
$envelope = $message->getEnvelope();

$request = [
'FromEmailAddress' => $envelope->getSender()->toString(),
'FromEmailAddress' => $this->stringifyAddress($envelope->getSender()),
'Destination' => [
'ToAddresses' => $this->stringifyAddresses($this->getRecipients($email, $envelope)),
],
Expand Down Expand Up @@ -114,15 +114,20 @@ private function getRecipients(Email $email, Envelope $envelope): array
protected function stringifyAddresses(array $addresses): array
{
return array_map(function (Address $a) {
// AWS does not support UTF-8 address
if (preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $name = $a->getName())) {
return sprintf('=?UTF-8?B?%s?= <%s>',
base64_encode($name),
$a->getEncodedAddress()
);
}

return $a->toString();
return $this->stringifyAddress($a);
}, $addresses);
}

protected function stringifyAddress(Address $a): string
{
// AWS does not support UTF-8 address
if (preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $name = $a->getName())) {
return sprintf('=?UTF-8?B?%s?= <%s>',
base64_encode($name),
$a->getEncodedAddress()
);
}

return $a->toString();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.