@@ -72,7 +72,7 @@ class node. Any parts of other types are each stored in separate files
7272an exception, the original message is bounced back to the sender with the
7373explanatory message given in the exception.
7474
75- $Id: mailgw.py,v 1.159.2.5 2005-06-24 06:48:17 richard Exp $
75+ $Id: mailgw.py,v 1.159.2.6 2005-06-24 07:17:08 richard Exp $
7676"""
7777__docformat__ = 'restructuredtext'
7878
@@ -81,7 +81,7 @@ class node. Any parts of other types are each stored in separate files
8181import traceback , MimeWriter , rfc822
8282
8383from roundup import hyperdb , date , password , rfc2822 , exceptions
84- from roundup .mailer import Mailer
84+ from roundup .mailer import Mailer , MessageSendError
8585
8686SENDMAILDEBUG = os .environ .get ('SENDMAILDEBUG' , '' )
8787
@@ -546,7 +546,19 @@ def handle_Message(self, message):
546546 # just inform the user that he is not authorized
547547 m = ['' ]
548548 m .append (str (value ))
549- self .mailer .bounce_message (message , [sendto [0 ][1 ]], m )
549+ try :
550+ self .mailer .bounce_message (message , [sendto [0 ][1 ]], m )
551+ except MessageSendError , error :
552+ # if the only reason the bounce failed is because of
553+ # invalid addresses to bounce the message back to, then
554+ # just discard the message - it's just not worth bothering
555+ # with (most likely spam / otherwise forged)
556+ invalid = True
557+ for address , (code , reason ) in error .keys ():
558+ if code != 550 :
559+ invalid = False
560+ if not invalid :
561+ raise
550562 except IgnoreMessage :
551563 # do not take any action
552564 # this exception is thrown when email should be ignored
0 commit comments