Opened 3 years ago

Last modified 2 years ago

#4904 enhancement new

Allow more informative messages in SMTP._messageHandled

Reported by: benwo Owned by:
Priority: normal Milestone:
Component: mail Keywords: smtpd smtp
Cc: Branch:
Author: Launchpad Bug:

Description

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[72.14.213.27] 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.

Change History (2)

comment:1 Changed 3 years ago by exarkun

  • Milestone Twisted 10.2 deleted

This would be a great feature. A few other people have asked for it over the years. It seems no one else ever filed a ticket, though. :)

comment:2 Changed 2 years ago by exarkun

#5769 was a duplicate of this.

Note: See TracTickets for help on using tickets.