Skip to content

[9.x] Sesv2client #37878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Mail/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'] ?? []
);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Illuminate/Mail/Transport/SesTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Illuminate\Mail\Transport;

use Aws\Ses\SesClient;
use Aws\SesV2\SesV2Client;
use Swift_Mime_SimpleMessage;

class SesTransport extends Transport
{
/**
* The Amazon SES instance.
*
* @var \Aws\Ses\SesClient
* @var \Aws\SesV2\SesV2Client
*/
protected $ses;

Expand All @@ -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;
Expand All @@ -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(),
],
Expand All @@ -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()
{
Expand Down
14 changes: 7 additions & 7 deletions tests/Mail/MailSesTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -83,7 +83,7 @@ public function testSesLocalConfiguration()
'region' => 'eu-west-1',
'options' => [
'ConfigurationSetName' => 'Laravel',
'Tags' => [
'EmailTags' => [
['Name' => 'Laravel', 'Value' => 'Framework'],
],
],
Expand Down Expand Up @@ -116,7 +116,7 @@ public function testSesLocalConfiguration()

$this->assertSame([
'ConfigurationSetName' => 'Laravel',
'Tags' => [
'EmailTags' => [
['Name' => 'Laravel', 'Value' => 'Framework'],
],
], $transport->getOptions());
Expand Down