Opened 8 years ago

Closed 8 years ago

#4903 enhancement closed duplicate (duplicate)

Allow more informative messages in SMTP._messageHandled

Reported by: ben wolfson Owned by:
Priority: normal Milestone: Twisted 10.2
Component: mail Keywords: smtpd smtp
Cc: Branch:


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[] said:

552-5.7.0 Our system detected an illegal attachment on your message. Please 552-5.7.0 visit 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.

Change History (1)

comment:1 Changed 8 years ago by ben wolfson

Resolution: duplicate
Status: newclosed

ignore this and see 4904, which has non-braindead formatting.

Note: See TracTickets for help on using tickets.