Skip to content

Commit fb33213

Browse files
authored
[9.x] Sesv2client (#37878)
* update SesTransport to use SesV2Client * update tests for SesV2Client usage
1 parent b52f82c commit fb33213

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/Illuminate/Mail/MailManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Illuminate\Mail;
44

5-
use Aws\Ses\SesClient;
5+
use Aws\SesV2\SesV2Client;
66
use Closure;
77
use GuzzleHttp\Client as HttpClient;
88
use Illuminate\Contracts\Mail\Factory as FactoryContract;
@@ -271,7 +271,7 @@ protected function createSesTransport(array $config)
271271
$config = Arr::except($config, ['transport']);
272272

273273
return new SesTransport(
274-
new SesClient($this->addSesCredentials($config)),
274+
new SesV2Client($this->addSesCredentials($config)),
275275
$config['options'] ?? []
276276
);
277277
}

src/Illuminate/Mail/Transport/SesTransport.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Illuminate\Mail\Transport;
44

5-
use Aws\Ses\SesClient;
5+
use Aws\SesV2\SesV2Client;
66
use Swift_Mime_SimpleMessage;
77

88
class SesTransport extends Transport
99
{
1010
/**
1111
* The Amazon SES instance.
1212
*
13-
* @var \Aws\Ses\SesClient
13+
* @var \Aws\SesV2\SesV2Client
1414
*/
1515
protected $ses;
1616

@@ -24,11 +24,11 @@ class SesTransport extends Transport
2424
/**
2525
* Create a new SES transport instance.
2626
*
27-
* @param \Aws\Ses\SesClient $ses
27+
* @param \Aws\SesV2\SesV2Client $ses
2828
* @param array $options
2929
* @return void
3030
*/
31-
public function __construct(SesClient $ses, $options = [])
31+
public function __construct(SesV2Client $ses, $options = [])
3232
{
3333
$this->ses = $ses;
3434
$this->options = $options;
@@ -41,10 +41,10 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
4141
{
4242
$this->beforeSendPerformed($message);
4343

44-
$result = $this->ses->sendRawEmail(
44+
$result = $this->ses->sendEmail(
4545
array_merge(
4646
$this->options, [
47-
'Source' => key($message->getSender() ?: $message->getFrom()),
47+
'FromEmailAddress' => key($message->getSender() ?: $message->getFrom()),
4848
'RawMessage' => [
4949
'Data' => $message->toString(),
5050
],
@@ -65,7 +65,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
6565
/**
6666
* Get the Amazon SES client for the SesTransport instance.
6767
*
68-
* @return \Aws\Ses\SesClient
68+
* @return \Aws\SesV2\SesV2Client
6969
*/
7070
public function ses()
7171
{

tests/Mail/MailSesTransportTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Illuminate\Tests\Mail;
44

5-
use Aws\Ses\SesClient;
5+
use Aws\SesV2\SesV2Client;
66
use Illuminate\Config\Repository;
77
use Illuminate\Container\Container;
88
use Illuminate\Mail\MailManager;
@@ -46,8 +46,8 @@ public function testSend()
4646
$message->setTo('me@example.com');
4747
$message->setBcc('you@example.com');
4848

49-
$client = $this->getMockBuilder(SesClient::class)
50-
->addMethods(['sendRawEmail'])
49+
$client = $this->getMockBuilder(SesV2Client::class)
50+
->addMethods(['sendEmail'])
5151
->disableOriginalConstructor()
5252
->getMock();
5353
$transport = new SesTransport($client);
@@ -57,9 +57,9 @@ public function testSend()
5757
$messageId = Str::random(32);
5858
$sendRawEmailMock = new sendRawEmailMock($messageId);
5959
$client->expects($this->once())
60-
->method('sendRawEmail')
60+
->method('sendEmail')
6161
->with($this->equalTo([
62-
'Source' => 'myself@example.com',
62+
'FromEmailAddress' => 'myself@example.com',
6363
'RawMessage' => ['Data' => (string) $message],
6464
]))
6565
->willReturn($sendRawEmailMock);
@@ -83,7 +83,7 @@ public function testSesLocalConfiguration()
8383
'region' => 'eu-west-1',
8484
'options' => [
8585
'ConfigurationSetName' => 'Laravel',
86-
'Tags' => [
86+
'EmailTags' => [
8787
['Name' => 'Laravel', 'Value' => 'Framework'],
8888
],
8989
],
@@ -116,7 +116,7 @@ public function testSesLocalConfiguration()
116116

117117
$this->assertSame([
118118
'ConfigurationSetName' => 'Laravel',
119-
'Tags' => [
119+
'EmailTags' => [
120120
['Name' => 'Laravel', 'Value' => 'Framework'],
121121
],
122122
], $transport->getOptions());

0 commit comments

Comments
 (0)