From 8c9c7d77b0b064bc2b66bafeeeb5140ed1feef16 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Tue, 20 Aug 2013 13:47:46 +0200 Subject: [PATCH] NL bounces: accept final-recipient starting with LOCAL; in findAddressInBounce Signed-off-by: Nicolas Iooss --- bin/newsletter.bounces.processor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/newsletter.bounces.processor.py b/bin/newsletter.bounces.processor.py index 18f0cc7..b17d945 100755 --- a/bin/newsletter.bounces.processor.py +++ b/bin/newsletter.bounces.processor.py @@ -123,6 +123,8 @@ def findSubject(message): _recipient_re = re.compile(r'^rfc822; ?(.+)$', re.I | re.U) +# Some MTA set the Final-Recipient with "LOCAL;" instead of "rfc822;" +_recipient_re2 = re.compile(r'^local; ?(.+)$', re.I | re.U) def findAddressInBounce(bounce): @@ -156,8 +158,11 @@ def findAddressInBounce(bounce): # Extract the faulty email address recipient_match = _recipient_re.search(content['Final-Recipient']) if recipient_match is None: - print('! Missing final recipient.') - return None + # Be nice, test another regexp + recipient_match = _recipient_re2.search(content['Final-Recipient']) + if recipient_match is None: + print('! Missing final recipient.') + return None email = recipient_match.group(1) # Check the action field if content['Action'].lower() != 'failed': -- 2.1.4