mailer icon indicating copy to clipboard operation
mailer copied to clipboard

SMTP backend not raising SMTPRecipientsRefused

Open hyperknot opened this issue 7 years ago • 1 comments

I am trying to send a message with wrong configured sender. I am getting the following line in the log:

2017-02-15 03:28:25,154 WARNI [marrow.mailer.transport.smtp] <[email protected]> REFUSED SMTPRecipientsRefused {u'[email protected]': (550, '5.1.0 <[email protected]>: Sender address rejected: User unknown in relay recipient table')}

My problem is that nothing else happens. That exception is not raised, just silently logged.

I believe an exception like this should be treated similarly to if a sending couldn't happen for example because of wrong password or something. That one raises an exception, this one does not.

The reason is this line is just silently "eating" all exceptions: https://github.com/marrow/mailer/blob/3995ef98a3f7feb75f1aeb652e6afe40a5c94def/marrow/mailer/transport/smtp.py#L105

hyperknot avatar Feb 15 '17 02:02 hyperknot

It's not "eating" exceptions, it's transforming them.

https://github.com/marrow/mailer/blob/3995ef98a3f7feb75f1aeb652e6afe40a5c94def/marrow/mailer/transport/smtp.py#L125-L129

Admittedly, this folds SMTPSenderRefused and SMTPRecipientsRefused into a single MessageFailedException whose args[0] references the actual exception that occurred. Additionally, it logs a message that should contain sufficient information to identify which recipients were rejected.

This clearly requires an explicit test case.

amcgregor avatar Oct 05 '23 15:10 amcgregor