-
Notifications
You must be signed in to change notification settings - Fork 335
Description
The default error handler (via MAILER_EMAIL_BACKEND setting) will log an info message and defer the mail if the error was one of the expected smtplib or socket errors.
This is fine.
On any other errors, the original exception is raised to make the user aware of the error.
Basically this is also fine but unfortunately breaks (probably intentionally) the loop over all queued mails in engine.send_all(). This leads to having all other queued mails to be unprocessed once an unexpected error occurs.
We actually experienced such a case recently where our code generated an invalid email which caused a ValueError in django.core.mail.message.sanitize_address and then all later queued mails were not processed anymore and the queue grew accordingly.
I see that this is basically intended behavior but I wonder if the above mentioned consequences are actually known.
For now, I overridden the default error handler to not raise an exception on unexpected errors but log them with error log level to get noticed but not break the processing of other mails in the queue.
@spookylukey are you open to PRs changing the current behavior and if so, do you have a preferred way of handling unexpected errors?