diff --git a/composer.json b/composer.json index 9fabdb59576a..3474c13f1e22 100644 --- a/composer.json +++ b/composer.json @@ -90,6 +90,7 @@ "pda/pheanstalk": "^4.0", "phpunit/phpunit": "^9.4", "predis/predis": "^1.1.2", + "symfony/amazon-mailer": "^6.0", "symfony/cache": "^6.0", "symfony/mailgun-mailer": "^6.0", "symfony/postmark-mailer": "^6.0" @@ -136,7 +137,7 @@ "ext-pcntl": "Required to use all features of the queue worker.", "ext-posix": "Required to use all features of the queue worker.", "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).", - "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.189.0).", + "aws/aws-sdk-php": "Required to use the SQS queue driver and DynamoDb failed job storage (^3.189.0).", "brianium/paratest": "Required to run tests in parallel (^6.0).", "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.12|^3.0).", "filp/whoops": "Required for friendly error pages in development (^2.8).", @@ -153,9 +154,10 @@ "predis/predis": "Required to use the predis connector (^1.1.2).", "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^5.0|^6.0).", + "symfony/amazon-mailer": "Required to enable support for the SES mail transport (^6.0).", "symfony/cache": "Required to PSR-6 cache bridge (^6.0).", "symfony/filesystem": "Required to enable support for relative symbolic links (^6.0).", - "symfony/http-client": "Required to enable support for the Mailgun mail transport (^6.0).", + "symfony/http-client": "Required to enable support for the Symfony mail transports (^6.0).", "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail transport (^6.0).", "symfony/postmark-mailer": "Required to enable support for the Postmark mail transport (^6.0).", "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0)." diff --git a/src/Illuminate/Mail/MailManager.php b/src/Illuminate/Mail/MailManager.php index 3d1c235efae6..cba62f2a9abe 100644 --- a/src/Illuminate/Mail/MailManager.php +++ b/src/Illuminate/Mail/MailManager.php @@ -2,17 +2,16 @@ namespace Illuminate\Mail; -use Aws\SesV2\SesV2Client; use Closure; use Illuminate\Contracts\Mail\Factory as FactoryContract; use Illuminate\Log\LogManager; use Illuminate\Mail\Transport\ArrayTransport; use Illuminate\Mail\Transport\LogTransport; -use Illuminate\Mail\Transport\SesTransport; use Illuminate\Support\Arr; use Illuminate\Support\Str; use InvalidArgumentException; use Psr\Log\LoggerInterface; +use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory; use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory; use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory; use Symfony\Component\Mailer\Transport\Dsn; @@ -237,33 +236,16 @@ protected function createSendmailTransport(array $config) */ protected function createSesTransport(array $config) { - $config = array_merge( - $this->app['config']->get('services.ses', []), - ['version' => 'latest', 'service' => 'email'], - $config - ); - - $config = Arr::except($config, ['transport']); - - return new SesTransport( - new SesV2Client($this->addSesCredentials($config)), - $config['options'] ?? [] - ); - } + $factory = new SesTransportFactory(); - /** - * Add the SES credentials to the configuration array. - * - * @param array $config - * @return array - */ - protected function addSesCredentials(array $config) - { - if (! empty($config['key']) && ! empty($config['secret'])) { - $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']); - } - - return $config; + return $factory->create(new Dsn( + 'ses+api', + 'default', + $config['key'], + $config['secret'], + $config['port'] ?? null, + $config + )); } /** diff --git a/src/Illuminate/Mail/Transport/SesTransport.php b/src/Illuminate/Mail/Transport/SesTransport.php deleted file mode 100644 index cae80810fd20..000000000000 --- a/src/Illuminate/Mail/Transport/SesTransport.php +++ /dev/null @@ -1,94 +0,0 @@ -ses = $ses; - $this->options = $options; - } - - /** - * {@inheritdoc} - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $this->beforeSendPerformed($message); - - $result = $this->ses->sendEmail( - array_merge( - $this->options, [ - 'Content' => [ - 'Raw' => ['Data' => $message->toString()], - ], - ] - ) - ); - - $messageId = $result->get('MessageId'); - - $message->getHeaders()->addTextHeader('X-Message-ID', $messageId); - $message->getHeaders()->addTextHeader('X-SES-Message-ID', $messageId); - - $this->sendPerformed($message); - - return $this->numberOfRecipients($message); - } - - /** - * Get the Amazon SES client for the SesTransport instance. - * - * @return \Aws\SesV2\SesV2Client - */ - public function ses() - { - return $this->ses; - } - - /** - * Get the transmission options being used by the transport. - * - * @return array - */ - public function getOptions() - { - return $this->options; - } - - /** - * Set the transmission options being used by the transport. - * - * @param array $options - * @return array - */ - public function setOptions(array $options) - { - return $this->options = $options; - } -} diff --git a/src/Illuminate/Mail/composer.json b/src/Illuminate/Mail/composer.json index 6c0439c3d86f..4f45de3a3dac 100755 --- a/src/Illuminate/Mail/composer.json +++ b/src/Illuminate/Mail/composer.json @@ -37,9 +37,9 @@ } }, "suggest": { - "aws/aws-sdk-php": "Required to use the SES mail driver (^3.189.0).", - "symfony/http-client": "Required to use the Mailgun mail driver (^6.0).", - "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail driver (^6.0).", + "symfony/amazon-mailer": "Required to enable support for the SES mail transport (^6.0).", + "symfony/http-client": "Required to use the Symfony mail transports (^6.0).", + "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail transport (^6.0).", "symfony/postmark-mailer": "Required to enable support for the Postmark mail transport (^6.0)." }, "config": {