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

SMTP backend not raising SMTPRecipientsRefused #74

Open
hyperknot opened this issue Feb 15, 2017 · 1 comment
Open

SMTP backend not raising SMTPRecipientsRefused #74

hyperknot opened this issue Feb 15, 2017 · 1 comment
Labels
2.enhancement A request for a new feature or altered behaviour. meta:discuss This issue may be larger in scope, requiring discussion. need:test Tests are required before acceptance. transport:smtp

Comments

@hyperknot
Copy link

hyperknot commented Feb 15, 2017

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:

self.send_with_smtp(message)

@amcgregor amcgregor added 2.enhancement A request for a new feature or altered behaviour. meta:discuss This issue may be larger in scope, requiring discussion. need:test Tests are required before acceptance. transport:smtp labels Oct 5, 2023
@amcgregor
Copy link
Member

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

except SMTPRecipientsRefused as e:
# All recipients were refused. Log which recipients.
# This allows you to automatically parse your logs for bad e-mail addresses.
log.warning("%s REFUSED %s %s", message.id, e.__class__.__name__, e)
raise MessageFailedException(str(e))

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.enhancement A request for a new feature or altered behaviour. meta:discuss This issue may be larger in scope, requiring discussion. need:test Tests are required before acceptance. transport:smtp
Projects
None yet
Development

No branches or pull requests

2 participants