mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Better logging for bounced emails
This commit is contained in:
parent
964294185e
commit
913edb706a
@ -24,6 +24,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
@ -164,7 +165,7 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
* this merges a text string with a json object
|
* this merges a text string with a json object
|
||||||
* need to harvest the ->Message property using the following
|
* need to harvest the ->Message property using the following
|
||||||
*/
|
*/
|
||||||
if (stripos($e->getMessage(), 'code 406') || stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) {
|
if (stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) {
|
||||||
$message = "Either Attachment too large, or recipient has been suppressed.";
|
$message = "Either Attachment too large, or recipient has been suppressed.";
|
||||||
|
|
||||||
$this->fail();
|
$this->fail();
|
||||||
@ -174,6 +175,20 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stripos($e->getMessage(), 'code 406')) {
|
||||||
|
|
||||||
|
$email = $this->nmo->to_user->email ?? '';
|
||||||
|
|
||||||
|
$message = "Recipient {$email} has been suppressed and cannot receive emails from you.";
|
||||||
|
|
||||||
|
$this->fail();
|
||||||
|
$this->logMailError($message, $this->company->clients()->first());
|
||||||
|
$this->cleanUpMailers();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//only report once, not on all tries
|
//only report once, not on all tries
|
||||||
if ($this->attempts() == $this->tries) {
|
if ($this->attempts() == $this->tries) {
|
||||||
/* If the is an entity attached to the message send a failure mailer */
|
/* If the is an entity attached to the message send a failure mailer */
|
||||||
|
@ -272,7 +272,8 @@ class Email implements ShouldQueue
|
|||||||
nlog("Mailer failed with {$e->getMessage()}");
|
nlog("Mailer failed with {$e->getMessage()}");
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
|
|
||||||
if (stripos($e->getMessage(), 'code 406') || stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) {
|
|
||||||
|
if (stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) {
|
||||||
$message = "Either Attachment too large, or recipient has been suppressed.";
|
$message = "Either Attachment too large, or recipient has been suppressed.";
|
||||||
|
|
||||||
$this->fail();
|
$this->fail();
|
||||||
@ -282,6 +283,21 @@ class Email implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stripos($e->getMessage(), 'code 406')) {
|
||||||
|
|
||||||
|
$address_object = reset($this->email_object->to);
|
||||||
|
|
||||||
|
$email = $address_object->address ?? '';
|
||||||
|
|
||||||
|
$message = "Recipient {$email} has been suppressed and cannot receive emails from you.";
|
||||||
|
|
||||||
|
$this->fail();
|
||||||
|
$this->logMailError($message, $this->company->clients()->first());
|
||||||
|
$this->cleanUpMailers();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post mark buries the proper message in a a guzzle response
|
* Post mark buries the proper message in a a guzzle response
|
||||||
* this merges a text string with a json object
|
* this merges a text string with a json object
|
||||||
|
Loading…
Reference in New Issue
Block a user