Mercurial > p > roundup > code
diff roundup/mailgw.py @ 3371:4f3285913a8c
discard, don't bounce messages to the mailgw when the messages's sender...
...is invalid (ie. when we try to bounce, we get a 550 "unknown user
account" response from the SMTP server) [SF#1190906]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 24 Jun 2005 07:16:01 +0000 |
| parents | a23863a95326 |
| children | 4a228402b810 |
line wrap: on
line diff
--- a/roundup/mailgw.py Fri Jun 24 07:06:14 2005 +0000 +++ b/roundup/mailgw.py Fri Jun 24 07:16:01 2005 +0000 @@ -72,7 +72,7 @@ an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.165 2005-06-24 06:43:03 richard Exp $ +$Id: mailgw.py,v 1.166 2005-06-24 07:16:01 richard Exp $ """ __docformat__ = 'restructuredtext' @@ -81,7 +81,7 @@ import traceback, MimeWriter, rfc822 from roundup import hyperdb, date, password, rfc2822, exceptions -from roundup.mailer import Mailer +from roundup.mailer import Mailer, MessageSendError SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '') @@ -546,7 +546,19 @@ # just inform the user that he is not authorized m = [''] m.append(str(value)) - self.mailer.bounce_message(message, [sendto[0][1]], m) + try: + self.mailer.bounce_message(message, [sendto[0][1]], m) + except MessageSendError, error: + # if the only reason the bounce failed is because of + # invalid addresses to bounce the message back to, then + # just discard the message - it's just not worth bothering + # with (most likely spam / otherwise forged) + invalid = True + for address, (code, reason) in error.keys(): + if code != 550: + invalid = False + if not invalid: + raise except IgnoreMessage: # do not take any action # this exception is thrown when email should be ignored
