From: Nicolas Iooss Date: Fri, 10 Jan 2014 18:14:26 +0000 (+0100) Subject: NL bounces: Some MTA don't set Final-Recipient in their bounces but use Remote-Recipi... X-Git-Tag: xorg/1.1.12~48 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=cfea91c4db1aa453b71e1fdae41403af7b3bb5f2;p=platal.git NL bounces: Some MTA don't set Final-Recipient in their bounces but use Remote-Recipient instead relay.supermarchesmatch.fr is such MTA Signed-off-by: Nicolas Iooss --- diff --git a/bin/newsletter.bounces.processor.py b/bin/newsletter.bounces.processor.py index 3206ef7..b75580d 100755 --- a/bin/newsletter.bounces.processor.py +++ b/bin/newsletter.bounces.processor.py @@ -165,10 +165,18 @@ def findAddressInBounce(bounce): print('! Not a valid bounce (expected text/plain, found %s).' % content.get_content_type()) return None # Extract the faulty email address - recipient_match = _recipient_re.search(content['Final-Recipient']) + # Some MTA don't set Final-Recipient but use Remote-Recipient instead + if 'Final-Recipient' in content: + final_recipient = content['Final-Recipient'] + elif 'Remote-Recipient' in content: + final_recipient = content['Remote-Recipient'] + else: + print('! Not a valid bounce (no Final-Recipient).') + return None + recipient_match = _recipient_re.search(final_recipient) if recipient_match is None: # Be nice, test another regexp - recipient_match = _recipient_re2.search(content['Final-Recipient']) + recipient_match = _recipient_re2.search(final_recipient) if recipient_match is None: print('! Missing final recipient.') return None