Skip to content

Commit

Permalink
Merge pull request #3 from mrDlef/transport-api-reply-to-support
Browse files Browse the repository at this point in the history
Fix support of replyTo on Api Transport
  • Loading branch information
gam6itko authored Nov 26, 2024
2 parents 927ecd6 + 6eb7213 commit fae4818
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Transport/SparkPostApiTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ private function buildContent(Email $email, Envelope $envelope): array
'subject' => $email->getSubject(),
'text' => $email->getTextBody(),
'html' => $email->getHtmlBody(),
'replyTo' => $email->getReplyTo(),
'reply_to' => implode(',', array_map(function ($replyTo) {
return $replyTo->toString();
}, $email->getReplyTo())),
'attachments' => $this->buildAttachments($email),
]);
}
Expand Down
30 changes: 30 additions & 0 deletions tests/Transport/SparkPostApiTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,36 @@ public function dataSend()

$json = <<<JSON
{
"recipients": [
{
"address": {
"email": "fabien@symfony.com"
}
}
],
"content": {
"from": {
"email": "gam6itko@gmail.com"
},
"subject": "Test email",
"text": "Test email for you!",
"reply_to": "no-reply@mail.com,\"Gam6itko\" <gam6itko+no-reply@gmail.com>,no-reply2@mail.com,\"Fabien\" <fabien+no-reply@symfony.com>"
}
}
JSON;
yield [
(new Email())
->from('sender@mail.com')
->to('recipient@mail.com')
->replyTo('no-reply@mail.com', new Address('gam6itko+no-reply@gmail.com', 'Gam6itko'), 'no-reply2@mail.com', new Address('fabien+no-reply@symfony.com', 'Fabien'))
->subject('Test email')
->text('Test email for you!'),
new Envelope(new Address('gam6itko@gmail.com'), [new Address('fabien@symfony.com')]),
$json,
];

$json = <<<JSON
{
"options": {
"click_tracking": false,
"transactional": true,
Expand Down

0 comments on commit fae4818

Please sign in to comment.