This commit is contained in:
paulwer 2024-03-17 08:43:40 +01:00
parent e443fb28ec
commit 522fbea475
4 changed files with 255 additions and 241 deletions

View File

@ -100,7 +100,7 @@ class NinjaMailerJob implements ShouldQueue
} }
$this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name); $this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name);
} elseif(isset($this->nmo->invitation->user)) { } elseif (isset ($this->nmo->invitation->user)) {
$this->nmo->mailable->replyTo($this->nmo->invitation->user->email, $this->nmo->invitation->user->present()->name()); $this->nmo->mailable->replyTo($this->nmo->invitation->user->email, $this->nmo->invitation->user->present()->name());
} else { } else {
$this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name()); $this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name());
@ -229,8 +229,8 @@ class NinjaMailerJob implements ShouldQueue
private function incrementEmailCounter(): void private function incrementEmailCounter(): void
{ {
if(in_array($this->mailer, ['default','mailgun'])) if (in_array($this->mailer, ['default', 'mailgun']))
Cache::increment("email_quota".$this->company->account->key); Cache::increment("email_quota" . $this->company->account->key);
} }
/** /**
@ -278,7 +278,7 @@ class NinjaMailerJob implements ShouldQueue
// 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.
try { try {
@ -286,7 +286,7 @@ class NinjaMailerJob implements ShouldQueue
$domain = explode("@", $email)[1] ?? ""; $domain = explode("@", $email)[1] ?? "";
$dns = dns_get_record($domain, DNS_MX); $dns = dns_get_record($domain, DNS_MX);
$server = $dns[0]["target"]; $server = $dns[0]["target"];
if(stripos($server, "outlook.com") !== false) { if (stripos($server, "outlook.com") !== false) {
$this->mailer = 'postmark'; $this->mailer = 'postmark';
$this->client_postmark_secret = config('services.postmark-outlook.token'); $this->client_postmark_secret = config('services.postmark-outlook.token');
@ -298,12 +298,12 @@ class NinjaMailerJob implements ShouldQueue
} }
$this->nmo $this->nmo
->mailable ->mailable
->from(config('services.postmark-outlook.from.address'), $email_from_name); ->from(config('services.postmark-outlook.from.address'), $email_from_name);
return $this; return $this;
} }
} catch(\Exception $e) { } catch (\Exception $e) {
nlog("problem switching outlook driver - hosted"); nlog("problem switching outlook driver - hosted");
nlog($e->getMessage()); nlog($e->getMessage());
@ -336,6 +336,10 @@ class NinjaMailerJob implements ShouldQueue
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setMailgunMailer(); $this->setMailgunMailer();
return $this; return $this;
case 'client_brevo':
$this->mailer = 'brevo';
$this->setBrevoMailer();
return $this;
case 'smtp': case 'smtp':
$this->mailer = 'smtp'; $this->mailer = 'smtp';
$this->configureSmtpMailer(); $this->configureSmtpMailer();
@ -385,11 +389,11 @@ class NinjaMailerJob implements ShouldQueue
} }
$user = $this->resolveSendingUser(); $user = $this->resolveSendingUser();
$sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email;
$this->nmo $this->nmo
->mailable ->mailable
->from($sending_email, $email_from_name); ->from($sending_email, $email_from_name);
} }
@ -503,8 +507,8 @@ class NinjaMailerJob implements ShouldQueue
$user = $this->resolveSendingUser(); $user = $this->resolveSendingUser();
$sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email;
$sending_user = (isset($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); $sending_user = (isset ($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name();
$this->nmo $this->nmo
->mailable ->mailable
@ -526,8 +530,8 @@ class NinjaMailerJob implements ShouldQueue
$user = $this->resolveSendingUser(); $user = $this->resolveSendingUser();
$sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email;
$sending_user = (isset($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); $sending_user = (isset ($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name();
$this->nmo $this->nmo
->mailable ->mailable
@ -549,8 +553,8 @@ class NinjaMailerJob implements ShouldQueue
$user = $this->resolveSendingUser(); $user = $this->resolveSendingUser();
$sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email;
$sending_user = (isset($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); $sending_user = (isset ($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name();
$this->nmo $this->nmo
->mailable ->mailable

View File

@ -130,18 +130,20 @@ class AppServiceProvider extends ServiceProvider
) )
); );
}); });
// Mailer::macro('brevo_config', function (string $key) { Mailer::macro('brevo_config', function (string $brevo_key) {
// // @phpstan-ignore /** @phpstan-ignore-next-line **/ // @phpstan-ignore /** @phpstan-ignore-next-line **/
// Mail::setSymfonyTransport((new BrevoTransportFactory)->create( Mailer::setSymfonyTransport(
// new Dsn( (new BrevoTransportFactory)->create(
// 'brevo+api', new Dsn(
// 'default', 'brevo+api',
// $key 'default',
// ) $brevo_key
// )); )
)
);
// return $this; return $this;
// }); });
} }

View File

@ -564,6 +564,10 @@ class Email implements ShouldQueue
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setMailgunMailer(); $this->setMailgunMailer();
return $this; return $this;
case 'client_brevo':
$this->mailer = 'brevo';
$this->setBrevoMailer();
return $this;
case 'smtp': case 'smtp':
$this->mailer = 'smtp'; $this->mailer = 'smtp';
$this->configureSmtpMailer(); $this->configureSmtpMailer();

430
composer.lock generated

File diff suppressed because it is too large Load Diff