diff options
-rw-r--r-- | Mailman/Bouncers/SimpleMatch.py | 40 | ||||
-rw-r--r-- | tests/bounces/simple_08.txt | 81 | ||||
-rw-r--r-- | tests/bounces/simple_09.txt | 27 | ||||
-rw-r--r-- | tests/test_bounces.py | 4 |
4 files changed, 140 insertions, 12 deletions
diff --git a/Mailman/Bouncers/SimpleMatch.py b/Mailman/Bouncers/SimpleMatch.py index 534fd862..a530f36f 100644 --- a/Mailman/Bouncers/SimpleMatch.py +++ b/Mailman/Bouncers/SimpleMatch.py @@ -87,6 +87,14 @@ PATTERNS = [ (_c('Unable to deliver message to the following address\(es\)\.'), _c('--- Original message follows\.'), _c('<(?P<addr>[^>]*)>:')), + # kundenserver.de + (_c('A message that you sent could not be delivered'), + _c('^--- The header of the original'), + _c('<(?P<addr>[^>]*)>')), + # another kundenserver.de + (_c('A message that you sent could not be delivered'), + _c('^--- The header of the original'), + _c('^(?P<addr>[^\s@]+@[^\s@:]+):')), # Next one goes here... ] @@ -99,19 +107,27 @@ def process(msg, patterns=None): # 0 = nothing seen yet # 1 = intro seen addrs = {} - state = 0 - for line in email.Iterators.body_line_iterator(msg): - if state == 0: - for scre, ecre, acre in patterns: + # MAS: This is a mess. The outer loop used to be over the message + # so we only looped through the message once. Looping through the + # message for each set of patterns is obviously way more work, but + # if we don't do it, problems arise because scre from the wrong + # pattern set matches first and then acre doesn't match. The + # alternative is to split things into separate modules, but then + # we process the message multiple times anyway. + for scre, ecre, acre in patterns: + state = 0 + for line in email.Iterators.body_line_iterator(msg): + if state == 0: if scre.search(line): state = 1 + if state == 1: + mo = acre.search(line) + if mo: + addr = mo.group('addr') + if addr: + addrs[mo.group('addr')] = 1 + elif ecre.search(line): break - if state == 1: - mo = acre.search(line) - if mo: - addr = mo.group('addr') - if addr: - addrs[mo.group('addr')] = 1 - elif ecre.search(line): - break + if addrs: + break return addrs.keys() diff --git a/tests/bounces/simple_08.txt b/tests/bounces/simple_08.txt new file mode 100644 index 00000000..c2067ce5 --- /dev/null +++ b/tests/bounces/simple_08.txt @@ -0,0 +1,81 @@ +Return-Path: <email@mydomain.de> +X-Original-To: newsletter-bounces@mydomain.de +Delivered-To: newsletter-bounces@mydomain.de +Received: by mailsrv.mycompanysname.lan (mycompanysname mail service, from userid 1004) + id AD5AC100A954; Tue, 28 Feb 2006 18:22:36 +0100 (CET) +X-Original-To: email@localhost.mydomain.de +Delivered-To: email@localhost.mydomain.de +Received: from localhost (localhost [127.0.0.1]) + by mailsrv.mycompanysname.lan (mycompanysname mail service) with ESMTP id B9B44100BF1B + for <email@localhost.mydomain.de>; Tue, 28 Feb 2006 18:22:34 +0100 (CET) +Received: from mailsrv.mycompanysname.lan ([127.0.0.1]) + by localhost (mydomain.de [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 32002-08 for <email@localhost.mydomain.de>; + Tue, 28 Feb 2006 18:22:33 +0100 (CET) +Received: from localhost (localhost [127.0.0.1]) + by mailsrv.mycompanysname.lan (mycompanysname mail service) with ESMTP id A093B100A955 + for <email@localhost>; Tue, 28 Feb 2006 18:22:33 +0100 (CET) +Delivery-Date: Tue, 28 Feb 2006 18:20:00 +0100 +Received-SPF: none (mxeu17: 212.227.126.240 is neither permitted nor denied by domain of mout-bounce.kundenserver.de) client-ip=212.227.126.240; envelope-from=postmaster@mout-bounce.kundenserver.de; helo=mout-bounce.kundenserver.de; +Received: from pop.1und1.com [212.227.15.161] + by localhost with POP3 (fetchmail-6.2.5.2) + for email@localhost (single-drop); Tue, 28 Feb 2006 18:22:33 +0100 (CET) +Received: from [212.227.126.240] (helo=mout-bounce.kundenserver.de) + by mx.kundenserver.de (node=mxeu17) with ESMTP (Nemesis), + id 0MKxIC-1FE8W00flx-0005g9 for newsletter-bounces@mydomain.de; Tue, 28 Feb 2006 18:20:00 +0100 +Received: from mout by mouteu2.kundenserver.de id 0MKvEC-1FE8V20Bkm-00025n; + Tue, 28 Feb 2006 18:19:00 +0100 +Date: Tue, 28 Feb 2006 18:19:00 +0100 +From: Mail Delivery System <mailer-daemon@kundenserver.de> +To: newsletter-bounces@mydomain.de +Subject: Mail delivery failed: returning message to sender +Message-Id: <0MKvEC-1FE8V20Bkm-00025n@mouteu2.kundenserver.de> +X-Original-Id: 0ML25U-1FE8V12M9j-0006lD +Envelope-To: newsletter-bounces@mydomain.de +X-Virus-Scanned: amavisd-new at mydomain.de + +This message was created automatically by mail delivery software. + +A message that you sent could not be delivered to one or more of +its recipients. The following addresses failed: + + <severin.XXX@t-online.de> + +SMTP error from remote server after RCPT command: +host mailin02.sul.t-online.de[194.25.134.9]: +550 user unknown + + +--- The header of the original message is following. --- + +Received: from [84.154.27.78] (helo=mailsrv.mycompanysname.lan) + by mrelayeu.kundenserver.de (node=mrelayeu5) with ESMTP (Nemesis), + id 0ML25U-1FE8V12M9j-0006lD; Tue, 28 Feb 2006 18:18:59 +0100 +Received: from localhost (localhost [127.0.0.1]) + by mailsrv.mycompanysname.lan (mycompanysname mail service) with ESMTP id EA2CD100A954 + for <severin.XXX@t-online.de>; Tue, 28 Feb 2006 18:18:58 +0100 (CET) +Received: from mailsrv.mycompanysname.lan ([127.0.0.1]) + by localhost (mydomain.de [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 31861-10 for <severin.XXX@t-online.de>; + Tue, 28 Feb 2006 18:18:58 +0100 (CET) +Received: from mailsrv.mycompanysname.lan (localhost [127.0.0.1]) + by mailsrv.mycompanysname.lan (mycompanysname mail service) with ESMTP id BB6BD100A308 + for <severin.XXX@t-online.de>; Tue, 28 Feb 2006 18:18:58 +0100 (CET) +MIME-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: =?iso-8859-1?q?Sie_haben_die_Mailingliste_=22newsletter=22_ab?= + =?iso-8859-1?q?bestellt?= +From: newsletter-bounces@mydomain.de +Message-ID: <mailman.0.1141147137.31940.newsletter@mydomain.de> +Date: Tue, 28 Feb 2006 18:18:57 +0100 +Precedence: bulk +X-BeenThere: newsletter@mydomain.de +X-Mailman-Version: 2.1.6 +List-Id: newsletter <newsletter.mydomain.de> +X-List-Administrivia: yes +To: severin.XXX@t-online.de +Sender: newsletter-bounces@mydomain.de +Errors-To: newsletter-bounces@mydomain.de +X-Virus-Scanned: amavisd-new at mydomain.de +X-Provags-ID: kundenserver.de abuse@kundenserver.de login:50f36a15497f230366e1019f5ac05f49 diff --git a/tests/bounces/simple_09.txt b/tests/bounces/simple_09.txt new file mode 100644 index 00000000..340c410b --- /dev/null +++ b/tests/bounces/simple_09.txt @@ -0,0 +1,27 @@ +Return-Path: <MAILER-DAEMON@sb7.songbird.com> +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by sb7.songbird.com (8.12.11/8.12.11) with ESMTP id k0TN474K030502 + for <gpc-talk-bounces@grizz.org>; Sun, 29 Jan 2006 15:04:07 -0800 +Received: from mx by mx.kundenserver.de id 0MKxMK-1F3LZu2Mij-0004S7; + Mon, 30 Jan 2006 00:03:26 +0100 +To: gpc-talk-bounces@grizz.org +From: "Mail Delivery System" <Mailer-Daemon@kundenserver.de> +Subject: Mail delivery failed: returning message to sender +Date: Mon, 30 Jan 2006 00:03:26 +0100 +Message-ID: <0MKxMK-1F3LZu2Mij-0004S7@mx.kundenserver.de> +Precedence: bulk +X-Original-ID: 0MKxMK-1F3LZt3R61-0004S7 +X-SongbirdInformation: support@songbird.com for more information +X-Songbird: Found to be clean +X-Songbird-From: + +This message was created automatically by mail delivery software. + +A message that you sent could not be delivered to one or more of +its recipients. This is a permanent error. The following addresses +failed: + +RobotMail@auto-walther.de: + quota exceeded + diff --git a/tests/test_bounces.py b/tests/test_bounces.py index 9b09b5a6..1269fd5f 100644 --- a/tests/test_bounces.py +++ b/tests/test_bounces.py @@ -47,6 +47,8 @@ class BounceTest(unittest.TestCase): ('SimpleMatch', 'simple_05.txt', ['rlosardo@sbcglobal.net']), ('SimpleMatch', 'simple_06.txt', ['dlyle@hamiltonpacific.com']), ('SimpleMatch', 'simple_07.txt', ['william.xxxx@sbcglobal.net']), + ('SimpleMatch', 'simple_08.txt', ['severin.XXX@t-online.de']), + ('SimpleMatch', 'simple_09.txt', ['RobotMail@auto-walther.de']), # SimpleWarning ('SimpleWarning', 'simple_03.txt', ['jacobus@geo.co.za']), # GroupWise @@ -55,6 +57,8 @@ class BounceTest(unittest.TestCase): # doesn't throw an exception, but we won't get any meaningful # addresses back from it. ('GroupWise', 'groupwise_02.txt', []), + # Actually, it's from Exchange, and Exchange does recognize it + ('Exchange', 'groupwise_02.txt', ['omarmo@thebas.com']), # Yale's own ('Yale', 'yale_01.txt', ['thomas.dtankengine@cs.yale.edu', 'thomas.dtankengine@yale.edu']), |