From eb3d3ca85873e0509ee53c7c8c066423e277e5bc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 17 Jun 2021 12:57:47 +1000 Subject: [PATCH] Fixes for mail providers --- app/Providers/MailCssInlinerServiceProvider.php | 8 ++++---- app/Providers/MailServiceProvider.php | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Providers/MailCssInlinerServiceProvider.php b/app/Providers/MailCssInlinerServiceProvider.php index 040bcd76ba..bdf47d34d5 100644 --- a/app/Providers/MailCssInlinerServiceProvider.php +++ b/app/Providers/MailCssInlinerServiceProvider.php @@ -33,9 +33,9 @@ class MailCssInlinerServiceProvider extends ServiceProvider return new CssInlinerPlugin([]); }); - $this->app->afterResolving('mail.manager', function (MailManager $mailManager) { - $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class)); - return $mailManager; - }); + // $this->app->afterResolving('mail.manager', function (MailManager $mailManager) { + // $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class)); + // return $mailManager; + // }); } } diff --git a/app/Providers/MailServiceProvider.php b/app/Providers/MailServiceProvider.php index 6f1da83db1..86919bcd25 100644 --- a/app/Providers/MailServiceProvider.php +++ b/app/Providers/MailServiceProvider.php @@ -3,10 +3,11 @@ namespace App\Providers; use App\Helpers\Mail\GmailTransportManager; +use App\Utils\CssInlinerPlugin; use Coconuts\Mail\PostmarkTransport; +use GuzzleHttp\Client as HttpClient; use Illuminate\Mail\MailServiceProvider as MailProvider; use Illuminate\Mail\TransportManager; -use GuzzleHttp\Client as HttpClient; class MailServiceProvider extends MailProvider { @@ -27,10 +28,6 @@ class MailServiceProvider extends MailProvider return new GmailTransportManager($app); }); - // $this->app->bind('mail.manager', function($app) { - // return new GmailTransportManager($app); - // }); - $this->app->bind('mailer', function ($app) { return $app->make('mail.manager')->mailer(); }); @@ -42,6 +39,10 @@ class MailServiceProvider extends MailProvider ); }); + $this->app->afterResolving('mail.manager', function (GmailTransportManager $mailManager) { + $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class)); + return $mailManager; + }); } protected function guzzle(array $config): HttpClient @@ -57,6 +58,7 @@ class MailServiceProvider extends MailProvider { return [ 'mail.manager', - 'mailer' ]; + 'mailer' + ]; } }