From 32cede1563e3f3ac72aac4ad7f695c03efc6e481 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 13 Apr 2015 18:15:38 +0200 Subject: [PATCH] [FIX] mail: ignore bounce mails. Note: bounces from marketing campaigns are already processed --- addons/mail/mail_thread.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 06975d2e078..f778f6e4e80 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -946,6 +946,16 @@ class mail_thread(osv.AbstractModel): in_reply_to = decode_header(message, 'In-Reply-To') thread_references = references or in_reply_to + # 0. First check if this is a bounce message or not. + # See http://datatracker.ietf.org/doc/rfc3462/?include_text=1 + # As all MTA does not respect this RFC (googlemail is one of them), + # we also need to verify if the message come from "mailer-daemon" + localpart = (tools.email_split(email_from) or [''])[0].split('@', 1)[0].lower() + if message.get_content_type() == 'multipart/report' or localpart == 'mailer-daemon': + _logger.info("Not routing bounce email from %s to %s with Message-Id %s", + email_from, email_to, message_id) + return [] + # 1. message is a reply to an existing message (exact match of message_id) ref_match = thread_references and tools.reference_re.search(thread_references) msg_references = mail_header_msgid_re.findall(thread_references)