From ebaa1b40712c5d509dd15631f0057e0d9b9027bd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 2 Nov 2022 17:30:55 +1100 Subject: [PATCH] Allow individual SMTP per company --- app/Jobs/Mail/NinjaMailerJob.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 4eef63382932..071e4106a421 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -133,10 +133,7 @@ class NinjaMailerJob implements ShouldQueue $this->nmo = null; $this->company = null; - - $mem_usage = memory_get_usage(); - - nlog('The script is now using: ' . round($mem_usage / 1024) . 'KBof memory.'); + app('queue.worker')->shouldQuit = 1; } catch (\Exception | \RuntimeException | \Google\Service\Exception $e) { @@ -179,7 +176,6 @@ class NinjaMailerJob implements ShouldQueue $message = null; $this->nmo = null; $this->company = null; - app('queue.worker')->shouldQuit = 1; } @@ -232,8 +228,34 @@ class NinjaMailerJob implements ShouldQueue break; } + + if(Ninja::isSelfHost()) + $this->setSelfHostMultiMailer(); + + } + private function setSelfHostMultiMailer() + { + + if (env($this->company->id . '_MAIL_HOST')) + { + + config([ + 'mail.mailers.smtp' => [ + 'transport' => 'smtp', + 'host' => env($this->company->id . '_MAIL_HOST'), + 'port' => env($this->company->id . '_MAIL_PORT'), + 'username' => env($this->company->id . '_MAIL_USERNAME'), + 'password' => env($this->company->id . '_MAIL_PASSWORD'), + ], + ]); + + } + + } + + private function setOfficeMailer() { $sending_user = $this->nmo->settings->gmail_sending_user_id;