From 410d16d88ce7cb6f31726f7f397cf6fd8c8100ef Mon Sep 17 00:00:00 2001 From: Chris Fidao Date: Thu, 1 Jul 2021 07:30:19 -0500 Subject: [PATCH 1/2] update SesTransport to use SesV2Client --- src/Illuminate/Mail/MailManager.php | 4 ++-- src/Illuminate/Mail/Transport/SesTransport.php | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Mail/MailManager.php b/src/Illuminate/Mail/MailManager.php index ad25ff5d7668..353788756130 100644 --- a/src/Illuminate/Mail/MailManager.php +++ b/src/Illuminate/Mail/MailManager.php @@ -2,7 +2,7 @@ namespace Illuminate\Mail; -use Aws\Ses\SesClient; +use Aws\SesV2\SesV2Client; use Closure; use GuzzleHttp\Client as HttpClient; use Illuminate\Contracts\Mail\Factory as FactoryContract; @@ -271,7 +271,7 @@ protected function createSesTransport(array $config) $config = Arr::except($config, ['transport']); return new SesTransport( - new SesClient($this->addSesCredentials($config)), + new SesV2Client($this->addSesCredentials($config)), $config['options'] ?? [] ); } diff --git a/src/Illuminate/Mail/Transport/SesTransport.php b/src/Illuminate/Mail/Transport/SesTransport.php index 76eb2a8a03c3..964fecb8878d 100644 --- a/src/Illuminate/Mail/Transport/SesTransport.php +++ b/src/Illuminate/Mail/Transport/SesTransport.php @@ -2,7 +2,7 @@ namespace Illuminate\Mail\Transport; -use Aws\Ses\SesClient; +use Aws\SesV2\SesV2Client; use Swift_Mime_SimpleMessage; class SesTransport extends Transport @@ -10,7 +10,7 @@ class SesTransport extends Transport /** * The Amazon SES instance. * - * @var \Aws\Ses\SesClient + * @var \Aws\SesV2\SesV2Client */ protected $ses; @@ -24,11 +24,11 @@ class SesTransport extends Transport /** * Create a new SES transport instance. * - * @param \Aws\Ses\SesClient $ses + * @param \Aws\SesV2\SesV2Client $ses * @param array $options * @return void */ - public function __construct(SesClient $ses, $options = []) + public function __construct(SesV2Client $ses, $options = []) { $this->ses = $ses; $this->options = $options; @@ -41,10 +41,10 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul { $this->beforeSendPerformed($message); - $result = $this->ses->sendRawEmail( + $result = $this->ses->sendEmail( array_merge( $this->options, [ - 'Source' => key($message->getSender() ?: $message->getFrom()), + 'FromEmailAddress' => key($message->getSender() ?: $message->getFrom()), 'RawMessage' => [ 'Data' => $message->toString(), ], @@ -65,7 +65,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul /** * Get the Amazon SES client for the SesTransport instance. * - * @return \Aws\Ses\SesClient + * @return \Aws\SesV2\SesV2Client */ public function ses() { From 1b292c20eb54aa7512157d856df5fa1c74351fdf Mon Sep 17 00:00:00 2001 From: Chris Fidao Date: Thu, 1 Jul 2021 07:30:34 -0500 Subject: [PATCH 2/2] update tests for SesV2Client usage --- tests/Mail/MailSesTransportTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Mail/MailSesTransportTest.php b/tests/Mail/MailSesTransportTest.php index ee2d4d35b826..a02b0152ca46 100644 --- a/tests/Mail/MailSesTransportTest.php +++ b/tests/Mail/MailSesTransportTest.php @@ -2,7 +2,7 @@ namespace Illuminate\Tests\Mail; -use Aws\Ses\SesClient; +use Aws\SesV2\SesV2Client; use Illuminate\Config\Repository; use Illuminate\Container\Container; use Illuminate\Mail\MailManager; @@ -46,8 +46,8 @@ public function testSend() $message->setTo('me@example.com'); $message->setBcc('you@example.com'); - $client = $this->getMockBuilder(SesClient::class) - ->addMethods(['sendRawEmail']) + $client = $this->getMockBuilder(SesV2Client::class) + ->addMethods(['sendEmail']) ->disableOriginalConstructor() ->getMock(); $transport = new SesTransport($client); @@ -57,9 +57,9 @@ public function testSend() $messageId = Str::random(32); $sendRawEmailMock = new sendRawEmailMock($messageId); $client->expects($this->once()) - ->method('sendRawEmail') + ->method('sendEmail') ->with($this->equalTo([ - 'Source' => 'myself@example.com', + 'FromEmailAddress' => 'myself@example.com', 'RawMessage' => ['Data' => (string) $message], ])) ->willReturn($sendRawEmailMock); @@ -83,7 +83,7 @@ public function testSesLocalConfiguration() 'region' => 'eu-west-1', 'options' => [ 'ConfigurationSetName' => 'Laravel', - 'Tags' => [ + 'EmailTags' => [ ['Name' => 'Laravel', 'Value' => 'Framework'], ], ], @@ -116,7 +116,7 @@ public function testSesLocalConfiguration() $this->assertSame([ 'ConfigurationSetName' => 'Laravel', - 'Tags' => [ + 'EmailTags' => [ ['Name' => 'Laravel', 'Value' => 'Framework'], ], ], $transport->getOptions());