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\SystemLog;
|
||||
use App\Models\User;
|
||||
use App\Repositories\ActivityRepository;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
@ -164,7 +165,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
* this merges a text string with a json object
|
||||
* 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.";
|
||||
|
||||
$this->fail();
|
||||
@ -174,6 +175,20 @@ class NinjaMailerJob implements ShouldQueue
|
||||
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
|
||||
if ($this->attempts() == $this->tries) {
|
||||
/* If the is an entity attached to the message send a failure mailer */
|
||||
|
@ -272,11 +272,27 @@ class Email implements ShouldQueue
|
||||
nlog("Mailer failed with {$e->getMessage()}");
|
||||
$message = $e->getMessage();
|
||||
|
||||
if (stripos($e->getMessage(), 'code 406') || stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) {
|
||||
$message = "Either Attachment too large, or recipient has been suppressed.";
|
||||
|
||||
if (stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) {
|
||||
$message = "Either Attachment too large, or recipient has been suppressed.";
|
||||
|
||||
$this->fail();
|
||||
$this->logMailError($e->getMessage(), $this->company->clients()->first());
|
||||
$this->cleanUpMailers();
|
||||
|
||||
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($e->getMessage(), $this->company->clients()->first());
|
||||
$this->logMailError($message, $this->company->clients()->first());
|
||||
$this->cleanUpMailers();
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user