Skip to content

Commit 986d4e2

Browse files
committed
bug #61335 [Mailer] [Resend] Add friendly name in the to field (antalaron)
This PR was merged into the 7.3 branch. Discussion ---------- [Mailer] [Resend] Add friendly name in the `to` field | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | n/a | License | MIT This PR adds support for friendly email address formatting (e.g. "John Doe <john@example.com>") in the `to` field. Although Resend's API accepts this format natively, the current implementation of the bridge does not pass it through correctly — names are silently discarded and only raw email addresses are used. This fix ensures that display names are preserved and passed to the API as intended. Commits ------- f9c0a3d Add friendly name in the `to` field
2 parents 1aac817 + f9c0a3d commit 986d4e2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Symfony/Component/Mailer/Bridge/Resend/Tests/Transport/ResendApiTransportTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testSendForIdnDomains()
152152

153153
$body = json_decode($options['body'], true);
154154
// to
155-
$this->assertSame('kältetechnik@xn--kltetechnik-xyz-0kb.de', $body['to'][0]);
155+
$this->assertSame('Kältetechnik Xyz <kältetechnik@xn--kltetechnik-xyz-0kb.de>', $body['to'][0]);
156156
// sender
157157
$this->assertStringContainsString('info@xn--kltetechnik-xyz-0kb.de', $body['from']);
158158
$this->assertStringContainsString('Kältetechnik Xyz', $body['from']);

src/Symfony/Component/Mailer/Bridge/Resend/Transport/ResendApiTransport.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function formatAddresses(array $addresses): array
8282
{
8383
$formattedAddresses = [];
8484
foreach ($addresses as $address) {
85-
$formattedAddresses[] = $address->getEncodedAddress();
85+
$formattedAddresses[] = $this->formatAddress($address);
8686
}
8787

8888
if (\count($formattedAddresses) > 50) {
@@ -99,8 +99,8 @@ private function getPayload(Email $email, Envelope $envelope): array
9999
'to' => $this->formatAddresses($this->getRecipients($email, $envelope)),
100100
'subject' => $email->getSubject(),
101101
];
102-
if ($attachements = $this->prepareAttachments($email)) {
103-
$payload['attachments'] = $attachements;
102+
if ($attachments = $this->prepareAttachments($email)) {
103+
$payload['attachments'] = $attachments;
104104
}
105105
if ($emails = $email->getReplyTo()) {
106106
$payload['reply_to'] = current($this->formatAddresses($emails));

0 commit comments

Comments
 (0)