diff roundup/mailgw.py @ 3374:3f12b4bcf796 maint-0.8

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Fri, 24 Jun 2005 07:19:04 +0000
parents 246fed02a51e
children aaf00739eb96
line wrap: on
line diff
--- a/roundup/mailgw.py	Fri Jun 24 07:17:08 2005 +0000
+++ b/roundup/mailgw.py	Fri Jun 24 07:19:04 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.159.2.5 2005-06-24 06:48:17 richard Exp $
+$Id: mailgw.py,v 1.159.2.6 2005-06-24 07:17:08 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

Roundup Issue Tracker: http://roundup-tracker.org/