Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop on mail error #31

Open
elpoleto opened this issue Jan 28, 2019 · 3 comments
Open

Loop on mail error #31

elpoleto opened this issue Jan 28, 2019 · 3 comments

Comments

@elpoleto
Copy link

Hello. i use MS Azure as smtp and when some errors occour the sneaker jump in a infinite loop of errors tring to sends mails, for example:

Expected response code 250 but got code "432", with message "432 4.3.2 STOREDRV.ClientSubmit; sender thread limit exceeded [Hostname=DB6PR0901MB0790.eurprd09.prod.outlook.com]^M
" {"exception":"[object] (Swift_TransportException(code: 432): Expected response code 250 but got code "432", with message "432 4.3.2 STOREDRV.ClientSubmit; sender thread limit exceeded .....

or

Expected response code 250 but got code "554", with message "554 5.2.0 STOREDRV.Submission.Exception:SubmissionQuotaExceededException; Failed to process message due to a permanent exception with message The message can't be submitted because the sender's submission quota was exceeded. SubmissionQuotaExceededException: The message can't be submitted because the sender's submission quota was exceeded.

my config capture is
'capture' => [ Symfony\Component\Debug\Exception\FatalErrorException::class, ],

but it goes in infinite loop

Any way to avoid that please?

@codegain
Copy link

codegain commented Feb 22, 2019

@elpoleto I will assume that you have queueing enabled, so that the error mails will be pushed onto it and then sent. If that's the case, Sneaker tries the following:

  1. Exception is thrown
  2. Exception is captured by Sneaker
  3. Sneaker generates an error mail and pushes it onto the queue
  4. The worker can't send the error mail, because the SMTP server responsed with an error
  5. The worker throws an exception
  6. Loop to 1.

This should generally be avoided by the code in Sneaker.php:83 where the "try-catch" block catches the exception from Sneaker. But if the mail is sent via the queue, the mailer does not throw an exception.

The only workaround I found is to parse the stack trace of the exception, look for "SquareBoat\Sneaker\ExceptionMailer" and then don't call app('sneaker')->captureException($e).

EDIT: I think this could be fixed by removing the "Queueable" trait and the "ShouldQueue" interface from the "ExceptionMailer" class.

@elpoleto
Copy link
Author

Thanks, for now i resolved starting the queue work with 3 tries, so i got only 3 error and the the loop is blocked.
I think is better wrap the Sneaker.php:111 line "$this->mailer->to($recipients)->send(new ExceptionMailer($subject, $body));" with a try except

@akaamitgupta
Copy link
Contributor

@elpoleto The capture() method of Sneaker.php is already wrapped into the try catch block. It's inside the ExceptionMailer class where the exception is thrown. So we can wrap that in a try catch block. I will soon implement this.

@codegain We cant remove the "ShouldQueue" interface as we want the mail to be sent using queue only. I don't find any good reason to remove it here. But making it configurable is much more appropriate. So will work on that soon or a PR is also welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants