Skip to content

Commit a486482

Browse files
author
Richard Jones
committed
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]
1 parent 03b3c78 commit a486482

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Fixed:
2727
- handle dropped properies in rdbms/metakit journal export (sf bug 1203569)
2828
- handle missing Subject lines better (sf bug 1198729)
2929
- sort/group by missing values correctly (sf bug 1198623)
30+
- discard, don't bounce messages to the mailgw when the messages's sender
31+
is invalid (ie. when we try to bounce, we get a 550 "unknown user
32+
account" response from the SMTP server) (sf bug 1190906)
3033

3134

3235
2005-05-02 0.8.3

roundup/mailgw.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class node. Any parts of other types are each stored in separate files
7272
an exception, the original message is bounced back to the sender with the
7373
explanatory message given in the exception.
7474
75-
$Id: mailgw.py,v 1.165 2005-06-24 06:43:03 richard Exp $
75+
$Id: mailgw.py,v 1.166 2005-06-24 07:16:01 richard Exp $
7676
"""
7777
__docformat__ = 'restructuredtext'
7878

@@ -81,7 +81,7 @@ class node. Any parts of other types are each stored in separate files
8181
import traceback, MimeWriter, rfc822
8282

8383
from roundup import hyperdb, date, password, rfc2822, exceptions
84-
from roundup.mailer import Mailer
84+
from roundup.mailer import Mailer, MessageSendError
8585

8686
SENDMAILDEBUG = 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

Comments
 (0)