send_store_mail misses some exceptions

Issue #1221 new
ke1g created an issue

In, in send_store_mail(), actually sending the mail is wrapped in a try - except block looking for SocketError. Errors due to bad email addresses, however, come back as instances of smtplib.SMTPException (and its derivatives), which are not instances of SocketError, so they just blow right on up the stack.

At the very least this means that you loose the logging done in the aforementioned except block. (And I guess the users sees a 500 error?)

For me it is a bit worse. I'm doing an SIM implementation. In the view that calls to report payment, I wind up calling order.order_success(), which attempts to send the user email at the address he entered on the form. This is before the order notification email is sent to the shop owner, so the exception prevents that mail too. Money has already changed hands at this point, so the shop owner would really like notice of the order.

I'm fine with catching the SMTPException in my view, but I'd like it if got called anyway. (Yes, I can call it myself if I get the exception, but its hard to know if it's already been done.

At the very least it would be nice if order_success_listener called send_order_notice before it called send_order_confirmation. I guess that I don't know whether there are side-effects of, for example, discount calculations, that make this ordering infeasible, but it would work for me.

Nicer would be if, in the event of an SMTPException, all mails were still tried, then the exception re-raised, or similar.

Bill, KE1G

Comments (1)

  1. Log in to comment