Updates for mailing logic

This commit is contained in:
David Bomba 2025-08-28 10:43:46 +10:00
parent 7db1402cb4
commit ce599d5787
2 changed files with 3 additions and 43 deletions

View File

@ -346,18 +346,13 @@ class NinjaMailerJob implements ShouldQueue
$t = app('translator'); $t = app('translator');
$t->replace(Ninja::transformTranslations($this->nmo->settings)); $t->replace(Ninja::transformTranslations($this->nmo->settings));
if(Ninja::isHosted() && $this->nmo?->transport == 'default') { if(Ninja::isHosted() && $this->nmo?->transport == 'default' && ($this->company->account->isNewHostedAccount() || !$this->company->account->isPaid())) {
$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()) {
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setHostedMailgunMailer(); $this->setHostedMailgunMailer();
return $this; return $this;
} }
if (Ninja::isHosted() && $this->company->account->isPaid() && $this->nmo->settings->email_sending_method == 'default') { if (Ninja::isHosted() && $this->company->account->isPaid() && $this->nmo->settings->email_sending_method == 'default') {
//check if outlook. //check if outlook.
@ -399,10 +394,6 @@ class NinjaMailerJob implements ShouldQueue
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setHostedMailgunMailer(); $this->setHostedMailgunMailer();
return $this; return $this;
case 'ses':
$this->mailer = 'ses';
$this->setHostedSesMailer();
return $this;
case 'gmail': case 'gmail':
$this->mailer = 'gmail'; $this->mailer = 'gmail';
$this->setGmailMailer(); $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 * Configures Mailgun using client supplied secret
* as the Mailer * as the Mailer

View File

@ -546,19 +546,6 @@ 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 * Sets the mail driver to use and applies any specific configuration
@ -568,7 +555,7 @@ class Email implements ShouldQueue
{ {
/** Force free/trials onto specific mail driver */ /** 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->mailer = 'mailgun';
$this->setHostedMailgunMailer(); $this->setHostedMailgunMailer();
return $this; return $this;
@ -614,10 +601,6 @@ class Email implements ShouldQueue
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setHostedMailgunMailer(); $this->setHostedMailgunMailer();
return $this; return $this;
case 'ses':
$this->mailer = 'ses';
$this->setHostedSesMailer();
return $this;
case 'gmail': case 'gmail':
$this->mailer = 'gmail'; $this->mailer = 'gmail';
$this->setGmailMailer(); $this->setGmailMailer();