From da2b44c0afdebddbf7dc39492a8e759493703bc5 Mon Sep 17 00:00:00 2001 From: Stefano Date: Tue, 14 Mar 2023 17:30:54 +0100 Subject: [PATCH 1/4] Upgrade L10 --- composer.json | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index b121d2df..55ba05e2 100755 --- a/composer.json +++ b/composer.json @@ -1,27 +1,26 @@ { - "name": "mettle/sendportal-core", - "homepage": "https://github.com/mettle/sendportal-core", + "name": "sabas/sendportal-core", + "homepage": "https://github.com/sabas/sendportal-core", "description": "Sendportal core functionality.", "type": "library", "license": "MIT", "authors": [], "require": { - "php": "^7.3 || ^8.0", "ext-json": "*", - "aws/aws-sdk-php-laravel": "^3.6", - "doctrine/dbal": "^3.0", - "illuminate/support": "^8.0", + "aws/aws-sdk-php-laravel": "^3.8", + "doctrine/dbal": "4.0.0-beta2", + "illuminate/support": "^10.0", "kriswallsmith/buzz": "^1.2", - "mailgun/mailgun-php": "^3.2", + "mailgun/mailgun-php": "^3.5", "mailjet/mailjet-apiv3-php": "^1.5", "nyholm/psr7": "^1.3", - "rap2hpoutre/fast-excel": "^2.3", + "rap2hpoutre/fast-excel": "^5.1", "sendgrid/sendgrid": "^7.9", "wildbit/postmark-php": "^4.0", "postal/postal": "^1.0" }, "require-dev": { - "orchestra/testbench": "^6.0", + "orchestra/testbench": "^8.0", "phpunit/phpunit": "^9.0", "roave/security-advisories": "dev-master" }, @@ -43,7 +42,10 @@ }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "php-http/discovery": true + } }, "extra": { "laravel": { From 1e5a5f11257474cf19f4ba217a10173217dfabe0 Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 15 Mar 2023 12:08:30 +0100 Subject: [PATCH 2/4] SMTP migrated to Symfony Mail --- src/Adapters/SmtpAdapter.php | 62 +++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/Adapters/SmtpAdapter.php b/src/Adapters/SmtpAdapter.php index ccafefe6..f284efca 100644 --- a/src/Adapters/SmtpAdapter.php +++ b/src/Adapters/SmtpAdapter.php @@ -4,68 +4,80 @@ use Illuminate\Support\Arr; use Sendportal\Base\Services\Messages\MessageTrackingOptions; -use Swift_Mailer; -use Swift_Message; -use Swift_SmtpTransport; -use Swift_TransportException; + +use Symfony\Component\Mailer\Transport; +use Symfony\Component\Mailer\Transport\Dsn; +use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; +use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransportFactory; +use Symfony\Component\Mailer\Mailer; +use Symfony\Component\Mime\Email; +use Symfony\Component\Mime\Address; +use Symfony\Component\Mailer\Exception\TransportException; class SmtpAdapter extends BaseMailAdapter { - /** @var Swift_Mailer */ + /** @var Mailer */ protected $client; - /** @var Swift_SmtpTransport */ + /** @var ESmtpTransport */ protected $transport; public function send(string $fromEmail, string $fromName, string $toEmail, string $subject, MessageTrackingOptions $trackingOptions, string $content): string { - $failedRecipients = []; - + // $failedRecipients = []; try { - $result = $this->resolveClient()->send($this->resolveMessage($subject, $content, $fromEmail, $fromName, $toEmail), $failedRecipients); - } catch (Swift_TransportException $e) { + $result = $this->resolveClient()->send($this->resolveMessage($subject, $content, $fromEmail, $fromName, $toEmail)); + } catch (TransportException $e) { return $this->resolveMessageId(0); } - return $this->resolveMessageId($result); } - protected function resolveClient(): Swift_Mailer + protected function resolveClient(): Mailer { if ($this->client) { return $this->client; } - $this->client = new Swift_Mailer($this->resolveTransport()); + $this->client = new Mailer($this->resolveTransport()); return $this->client; } - protected function resolveTransport(): Swift_SmtpTransport + protected function resolveTransport(): EsmtpTransport { if ($this->transport) { return $this->transport; } - $this->transport = new Swift_SmtpTransport( + $factory = new EsmtpTransportFactory(); + + $encryption = Arr::get($this->config, 'encryption'); + + $scheme = !is_null($encryption) && $encryption === 'tls' + ? ((Arr::get($this->config, 'port') == 465) ? 'smtps' : 'smtp') + : ''; + + $dsn = new Dsn( + $scheme, Arr::get($this->config, 'host'), - Arr::get($this->config, 'port'), - Arr::get($this->config, 'encryption') + Arr::get($this->config, 'username'), + Arr::get($this->config, 'password'), + Arr::get($this->config, 'port') ); - $this->transport->setUsername(Arr::get($this->config, 'username')); - $this->transport->setPassword(Arr::get($this->config, 'password')); - $this->transport->setAuthMode('login'); + $this->transport = $factory->create($dsn); return $this->transport; } - protected function resolveMessage(string $subject, string $content, string $fromEmail, string $fromName, string $toEmail): Swift_Message + protected function resolveMessage(string $subject, string $content, string $fromEmail, string $fromName, string $toEmail): Email { - $msg = new Swift_Message($subject, $content, 'text/html'); - - $msg->setTo($toEmail); - $msg->setFrom($fromEmail, $fromName); + $msg = (new Email()) + ->from(new Address($fromEmail, $fromName)) + ->to($toEmail) + ->subject($subject) + ->html($content); return $msg; } From 0ce472cdb80560e4defa3c61c9e248be11fd187a Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 15 Mar 2023 16:38:47 +0100 Subject: [PATCH 3/4] Clarify dropdown function in subscribers list --- resources/views/subscribers/index.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/subscribers/index.blade.php b/resources/views/subscribers/index.blade.php index 22f7b832..8da55182 100644 --- a/resources/views/subscribers/index.blade.php +++ b/resources/views/subscribers/index.blade.php @@ -46,8 +46,8 @@ class="btn btn-md btn-light">{{ __('Clear') }} @slot('right')