From ce599d57872f2ae073f23a33ebf381aa352ddaa0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 28 Aug 2025 10:43:46 +1000 Subject: [PATCH] Updates for mailing logic --- app/Jobs/Mail/NinjaMailerJob.php | 27 ++------------------------- app/Services/Email/Email.php | 19 +------------------ 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 38c8afdd67..2a0caf5a17 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -346,18 +346,13 @@ class NinjaMailerJob implements ShouldQueue $t = app('translator'); $t->replace(Ninja::transformTranslations($this->nmo->settings)); - if(Ninja::isHosted() && $this->nmo?->transport == 'default') { - $this->mailer = config('mail.default'); - return $this; - } - - /** Force free/trials onto specific mail driver */ - if ($this->nmo->settings->email_sending_method == 'default' && $this->company->account->isNewHostedAccount()) { + if(Ninja::isHosted() && $this->nmo?->transport == 'default' && ($this->company->account->isNewHostedAccount() || !$this->company->account->isPaid())) { $this->mailer = 'mailgun'; $this->setHostedMailgunMailer(); return $this; } + if (Ninja::isHosted() && $this->company->account->isPaid() && $this->nmo->settings->email_sending_method == 'default') { //check if outlook. @@ -399,10 +394,6 @@ class NinjaMailerJob implements ShouldQueue $this->mailer = 'mailgun'; $this->setHostedMailgunMailer(); return $this; - case 'ses': - $this->mailer = 'ses'; - $this->setHostedSesMailer(); - return $this; case 'gmail': $this->mailer = 'gmail'; $this->setGmailMailer(); @@ -584,20 +575,6 @@ class NinjaMailerJob implements ShouldQueue } - private function setHostedSesMailer() - { - - if (property_exists($this->nmo->settings, 'email_from_name') && strlen($this->nmo->settings->email_from_name) > 1) { - $email_from_name = $this->nmo->settings->email_from_name; - } else { - $email_from_name = $this->company->present()->name(); - } - - $this->nmo - ->mailable - ->from(config('services.ses.from.address'), $email_from_name); - - } /** * Configures Mailgun using client supplied secret * as the Mailer diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index f73b15a8aa..da12cded99 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -546,20 +546,7 @@ class Email implements ShouldQueue } - private function setHostedSesMailer() - { - - if (property_exists($this->email_object->settings, 'email_from_name') && strlen($this->email_object->settings->email_from_name) > 1) { - $email_from_name = $this->email_object->settings->email_from_name; - } else { - $email_from_name = $this->company->present()->name(); - } - $this->mailable - ->from(config('services.ses.from.address'), $email_from_name); - - } - /** * Sets the mail driver to use and applies any specific configuration * the the mailable @@ -568,7 +555,7 @@ class Email implements ShouldQueue { /** Force free/trials onto specific mail driver */ - if ($this->email_object->settings->email_sending_method == 'default' && $this->company->account->isNewHostedAccount()) { + if ($this->email_object->settings->email_sending_method == 'default' && (!$this->company->account->isPaid() || $this->company->account->isNewHostedAccount())) { $this->mailer = 'mailgun'; $this->setHostedMailgunMailer(); return $this; @@ -614,10 +601,6 @@ class Email implements ShouldQueue $this->mailer = 'mailgun'; $this->setHostedMailgunMailer(); return $this; - case 'ses': - $this->mailer = 'ses'; - $this->setHostedSesMailer(); - return $this; case 'gmail': $this->mailer = 'gmail'; $this->setGmailMailer();