Catches for incorrectly configured mail servers

This commit is contained in:
David Bomba 2024-05-27 06:46:26 +10:00
parent 9c7f1e888f
commit 5ed27fe747
2 changed files with 16 additions and 4 deletions

View File

@ -152,24 +152,31 @@ class NinjaMailerJob implements ShouldQueue
LightLogs::create(new EmailSuccess($this->nmo->company->company_key, $this->nmo->mailable->subject))
->send();
} catch (\Symfony\Component\Mime\Exception\RfcComplianceException $e) {
nlog("Mailer failed with a Logic Exception {$e->getMessage()}");
$this->fail();
$this->cleanUpMailers();
$this->logMailError($e->getMessage(), $this->company->clients()->first());
return;
} catch (\Symfony\Component\Mime\Exception\LogicException $e) {
}
catch (\Symfony\Component\Mime\Exception\RfcComplianceException $e) {
nlog("Mailer failed with a Logic Exception {$e->getMessage()}");
$this->fail();
$this->cleanUpMailers();
$this->logMailError($e->getMessage(), $this->company->clients()->first());
return;
}
catch (\Symfony\Component\Mime\Exception\LogicException $e) {
nlog("Mailer failed with a Logic Exception {$e->getMessage()}");
$this->fail();
$this->cleanUpMailers();
$this->logMailError($e->getMessage(), $this->company->clients()->first());
return;
}
catch(\Symfony\Component\Mailer\Transport\Dsn $e){
nlog("Incorrectly configured mail server - setting to default mail driver.");
$this->nmo->settings->email_sending_method = 'default';
return $this->setMailDriver();
}
catch(\Google\Service\Exception $e){
if ($e->getCode() == '429') {
$message = "Google rate limiting triggered, we are queueing based on GMail requirements.";
$message = "Google rate limiting triggered, we are queueing based on Gmail requirements.";
$this->logMailError($message, $this->company->clients()->first());
sleep(rand(1, 2));
$this->release(900);

View File

@ -303,11 +303,16 @@ class Email implements ShouldQueue
$this->logMailError($e->getMessage(), $this->company->clients()->first());
return;
}
catch(\Symfony\Component\Mailer\Transport\Dsn $e){
nlog("Incorrectly configured mail server - setting to default mail driver.");
$this->email_object->settings->email_sending_method = 'default';
return $this->setMailDriver();
}
catch(\Google\Service\Exception $e){
if ($e->getCode() == '429') {
$message = "Google rate limiting triggered, we are queueing based on GMail requirements.";
$message = "Google rate limiting triggered, we are queueing based on Gmail requirements.";
$this->logMailError($message, $this->company->clients()->first());
sleep(rand(1, 2));
$this->release(900);