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 6dbac13

Browse filesBrowse files
author
Michaël Perrin
committed
[Mailer] Fix Mandrill Transport API payload with named addresses
1 parent 0c77296 commit 6dbac13
Copy full SHA for 6dbac13

File tree

1 file changed

+14
-3
lines changed
Filter options

1 file changed

+14
-3
lines changed

‎src/Symfony/Component/Mailer/Bridge/Mailchimp/Http/Api/MandrillTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Mailchimp/Http/Api/MandrillTransport.php
+14-3Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Mailer\SmtpEnvelope;
1818
use Symfony\Component\Mailer\Transport\Http\Api\AbstractApiTransport;
1919
use Symfony\Component\Mime\Email;
20+
use Symfony\Component\Mime\NamedAddress;
2021
use Symfony\Contracts\HttpClient\HttpClientInterface;
2122

2223
/**
@@ -60,11 +61,15 @@ private function getPayload(Email $email, SmtpEnvelope $envelope): array
6061
'html' => $email->getHtmlBody(),
6162
'text' => $email->getTextBody(),
6263
'subject' => $email->getSubject(),
63-
'from_email' => $envelope->getSender()->toString(),
64+
'from_email' => $envelope->getSender()->getAddress(),
6465
'to' => $this->getRecipients($email, $envelope),
6566
],
6667
];
6768

69+
if ($envelope->getSender() instanceof NamedAddress) {
70+
$payload['message']['from_name'] = $envelope->getSender()->getName();
71+
}
72+
6873
foreach ($email->getAttachments() as $attachment) {
6974
$headers = $attachment->getPreparedHeaders();
7075
$disposition = $headers->getHeaderBody('Content-Disposition');
@@ -104,10 +109,16 @@ protected function getRecipients(Email $email, SmtpEnvelope $envelope): array
104109
$type = 'cc';
105110
}
106111

107-
$recipients[] = [
108-
'email' => $recipient->toString(),
112+
$recipientPayload = [
113+
'email' => $recipient->getAddress(),
109114
'type' => $type,
110115
];
116+
117+
if ($recipient instanceof NamedAddress) {
118+
$recipientPayload['name'] = $recipient->getName();
119+
}
120+
121+
$recipients[] = $recipientPayload;
111122
}
112123

113124
return $recipients;

0 commit comments

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