Updates for mailgun

This commit is contained in:
David Bomba 2024-01-17 08:44:39 +11:00
parent 2e51bbd655
commit 41daa63056
3 changed files with 38 additions and 0 deletions

View File

@ -258,9 +258,11 @@ class NinjaMailerJob implements ShouldQueue
switch ($this->nmo->settings->email_sending_method) { switch ($this->nmo->settings->email_sending_method) {
case 'default': case 'default':
$this->mailer = config('mail.default'); $this->mailer = config('mail.default');
// $this->setHostedMailgunMailer(); //should only be activated if hosted platform needs to fall back to mailgun
break; break;
case 'mailgun': case 'mailgun':
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setHostedMailgunMailer();
break; break;
case 'gmail': case 'gmail':
$this->mailer = 'gmail'; $this->mailer = 'gmail';
@ -368,6 +370,21 @@ class NinjaMailerJob implements ShouldQueue
return $user; return $user;
} }
private function setHostedMailgunMailer()
{
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.mailgun.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

@ -463,6 +463,21 @@ class Email implements ShouldQueue
return false; return false;
} }
private function setHostedMailgunMailer()
{
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.mailgun.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
* the the mailable * the the mailable
@ -472,9 +487,11 @@ class Email implements ShouldQueue
switch ($this->email_object->settings->email_sending_method) { switch ($this->email_object->settings->email_sending_method) {
case 'default': case 'default':
$this->mailer = config('mail.default'); $this->mailer = config('mail.default');
// $this->setHostedMailgunMailer(); //should only be activated if hosted platform needs to fall back to mailgun
break; break;
case 'mailgun': case 'mailgun':
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setHostedMailgunMailer();
break; break;
case 'gmail': case 'gmail':
$this->mailer = 'gmail'; $this->mailer = 'gmail';

View File

@ -24,6 +24,10 @@ return [
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
'webhook_signing_key' => env('MAILGUN_WEBHOOK_SIGNING_KEY', ''), 'webhook_signing_key' => env('MAILGUN_WEBHOOK_SIGNING_KEY', ''),
'scheme' => 'https', 'scheme' => 'https',
'from' => [
'address' => env('MAILGUN_FROM_ADDRESS', ''),
'name' => env('MAILGUN_FROM_NAME', ''),
],
], ],
'postmark' => [ 'postmark' => [