Skip to content

Commit df9100e

Browse files
authored
[9.x] Fix SES V2 Transport "reply to" addresses (#47522)
* [9.x] Fix SES V2 Transport "reply to" addresses * fix: SES mail transport tests
1 parent e217dca commit df9100e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/Illuminate/Mail/Transport/SesV2Transport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function doSend(SentMessage $message): void
6060
$result = $this->ses->sendEmail(
6161
array_merge(
6262
$options, [
63-
'ReplyToAddresses' => [$message->getEnvelope()->getSender()->toString()],
63+
'Source' => $message->getEnvelope()->getSender()->toString(),
6464
'Destination' => [
6565
'ToAddresses' => collect($message->getEnvelope()->getRecipients())
6666
->map

tests/Mail/MailSesTransportTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Mockery as m;
1212
use PHPUnit\Framework\TestCase;
1313
use Symfony\Component\Mailer\Header\MetadataHeader;
14+
use Symfony\Component\Mime\Address;
1415
use Symfony\Component\Mime\Email;
1516

1617
class MailSesTransportTest extends TestCase
@@ -56,6 +57,7 @@ public function testSend()
5657
$message->sender('[email protected]');
5758
$message->to('[email protected]');
5859
$message->bcc('[email protected]');
60+
$message->replyTo(new Address('[email protected]', 'Taylor Otwell'));
5961
$message->getHeaders()->add(new MetadataHeader('FooTag', 'TagValue'));
6062

6163
$client = m::mock(SesClient::class);
@@ -68,7 +70,8 @@ public function testSend()
6870
->with(m::on(function ($arg) {
6971
return $arg['Source'] === '[email protected]' &&
7072
$arg['Destinations'] === ['[email protected]', '[email protected]'] &&
71-
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']];
73+
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']] &&
74+
strpos($arg['RawMessage']['Data'], 'Reply-To: Taylor Otwell <[email protected]>') !== false;
7275
}))
7376
->andReturn($sesResult);
7477

tests/Mail/MailSesV2TransportTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Mockery as m;
1212
use PHPUnit\Framework\TestCase;
1313
use Symfony\Component\Mailer\Header\MetadataHeader;
14+
use Symfony\Component\Mime\Address;
1415
use Symfony\Component\Mime\Email;
1516

1617
class MailSesV2TransportTest extends TestCase
@@ -56,6 +57,7 @@ public function testSend()
5657
$message->sender('[email protected]');
5758
$message->to('[email protected]');
5859
$message->bcc('[email protected]');
60+
$message->replyTo(new Address('[email protected]', 'Taylor Otwell'));
5961
$message->getHeaders()->add(new MetadataHeader('FooTag', 'TagValue'));
6062

6163
$client = m::mock(SesV2Client::class);
@@ -66,10 +68,10 @@ public function testSend()
6668
->andReturn('ses-message-id');
6769
$client->shouldReceive('sendEmail')->once()
6870
->with(m::on(function ($arg) {
69-
return count($arg['ReplyToAddresses']) === 1 &&
70-
$arg['ReplyToAddresses'][0] === '[email protected]' &&
71+
return $arg['Source'] === '[email protected]' &&
7172
$arg['Destination']['ToAddresses'] === ['[email protected]', '[email protected]'] &&
72-
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']];
73+
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']] &&
74+
strpos($arg['Content']['Raw']['Data'], 'Reply-To: Taylor Otwell <[email protected]>') !== false;
7375
}))
7476
->andReturn($sesResult);
7577

0 commit comments

Comments
 (0)