Skip to content

Commit

Permalink
[9.x] Fix SES V2 Transport "reply to" addresses (#47522)
Browse files Browse the repository at this point in the history
* [9.x] Fix SES V2 Transport "reply to" addresses

* fix: SES mail transport tests
  • Loading branch information
jacobmllr95 authored Jun 21, 2023
1 parent e217dca commit df9100e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/Transport/SesV2Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function doSend(SentMessage $message): void
$result = $this->ses->sendEmail(
array_merge(
$options, [
'ReplyToAddresses' => [$message->getEnvelope()->getSender()->toString()],
'Source' => $message->getEnvelope()->getSender()->toString(),
'Destination' => [
'ToAddresses' => collect($message->getEnvelope()->getRecipients())
->map
Expand Down
5 changes: 4 additions & 1 deletion tests/Mail/MailSesTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;

class MailSesTransportTest extends TestCase
Expand Down Expand Up @@ -56,6 +57,7 @@ public function testSend()
$message->sender('myself@example.com');
$message->to('me@example.com');
$message->bcc('you@example.com');
$message->replyTo(new Address('taylor@example.com', 'Taylor Otwell'));
$message->getHeaders()->add(new MetadataHeader('FooTag', 'TagValue'));

$client = m::mock(SesClient::class);
Expand All @@ -68,7 +70,8 @@ public function testSend()
->with(m::on(function ($arg) {
return $arg['Source'] === 'myself@example.com' &&
$arg['Destinations'] === ['me@example.com', 'you@example.com'] &&
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']];
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']] &&
strpos($arg['RawMessage']['Data'], 'Reply-To: Taylor Otwell <taylor@example.com>') !== false;
}))
->andReturn($sesResult);

Expand Down
8 changes: 5 additions & 3 deletions tests/Mail/MailSesV2TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;

class MailSesV2TransportTest extends TestCase
Expand Down Expand Up @@ -56,6 +57,7 @@ public function testSend()
$message->sender('myself@example.com');
$message->to('me@example.com');
$message->bcc('you@example.com');
$message->replyTo(new Address('taylor@example.com', 'Taylor Otwell'));
$message->getHeaders()->add(new MetadataHeader('FooTag', 'TagValue'));

$client = m::mock(SesV2Client::class);
Expand All @@ -66,10 +68,10 @@ public function testSend()
->andReturn('ses-message-id');
$client->shouldReceive('sendEmail')->once()
->with(m::on(function ($arg) {
return count($arg['ReplyToAddresses']) === 1 &&
$arg['ReplyToAddresses'][0] === 'myself@example.com' &&
return $arg['Source'] === 'myself@example.com' &&
$arg['Destination']['ToAddresses'] === ['me@example.com', 'you@example.com'] &&
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']];
$arg['Tags'] === [['Name' => 'FooTag', 'Value' => 'TagValue']] &&
strpos($arg['Content']['Raw']['Data'], 'Reply-To: Taylor Otwell <taylor@example.com>') !== false;
}))
->andReturn($sesResult);

Expand Down

0 comments on commit df9100e

Please sign in to comment.