Ticket #4904 enhancement new
Allow more informative messages in SMTP._messageHandled
|Reported by:||benwo||Owned by:|
Currently if a class implementing IMessage signals an error in eomReceived, the outcome is the same no matter what:
825 def _messageHandled(self, resultList): 826 failures = 0 827 for (success, result) in resultList: 828 if not success: 829 failures += 1 830 log.err(result) 831 if failures: 832 msg = 'Could not send e-mail' 833 L = len(resultList) 834 if L > 1: 835 msg += ' (%d failures out of %d recipients)' % (failures, L) 836 self.sendCode(550, msg) 837 else: 838 self.sendCode(250, 'Delivery in progress')
However, I'd like to be able to implement something like what google does with attachments, where having certain attachments causes the message to be rejected:
host gmail-smtp-in.l.google.com[188.8.131.52] said: 552-5.7.0 Our system detected an illegal attachment on your message. Please 552-5.7.0 visit http://mail.google.com/support/bin/answer.py?answer=6590 to 552 5.7.0 review our attachment guidelines. y9si11405790wfj.64 (in reply to end of DATA command)
IMessage.eomReceived() is the right place to look for these attachments, and that's not a big deal (and not an issue for twisted, anyway). However, there's no way to signal to the client *why* the message is being rejected. It would be nice if there were a way to signal to _messageHandled that it should inspect the result in the case of failure and use it to construct a message to the client, rather than using the single opaque message no matter what.