From 0843df213c808df2291f180d44ff9efc3c1c879e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 24 Aug 2016 12:47:45 +0200 Subject: [PATCH] [FIX][IMP] mail, mass_mailing: improve making of Return-Path alias Previously Return-Path were composed using bounce_alias--- . However this may lead to return adresses not supported by the incoming mail server. We now form the bounce alias using bounce_alis+ --. Using a + indicates that the right part of the address is for information and used to manage the bounce. Only the left part is used for the email routing, allowing the return email to effectively land in the alias mailbox. --- addons/mail/models/mail_mail.py | 4 ++-- addons/mass_mailing/models/mail_thread.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index aecb32cb5ac..5d90c54c0af 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -222,9 +222,9 @@ class MailMail(models.Model): catchall_domain = self.env['ir.config_parameter'].get_param("mail.catchall.domain") if bounce_alias and catchall_domain: if mail.model and mail.res_id: - headers['Return-Path'] = '%s-%d-%s-%d@%s' % (bounce_alias, mail.id, mail.model, mail.res_id, catchall_domain) + headers['Return-Path'] = '%s+%d-%s-%d@%s' % (bounce_alias, mail.id, mail.model, mail.res_id, catchall_domain) else: - headers['Return-Path'] = '%s-%d@%s' % (bounce_alias, mail.id, catchall_domain) + headers['Return-Path'] = '%s+%d@%s' % (bounce_alias, mail.id, catchall_domain) if mail.headers: try: headers.update(safe_eval(mail.headers)) diff --git a/addons/mass_mailing/models/mail_thread.py b/addons/mass_mailing/models/mail_thread.py index 0931271509d..af5782b9360 100644 --- a/addons/mass_mailing/models/mail_thread.py +++ b/addons/mass_mailing/models/mail_thread.py @@ -29,7 +29,7 @@ class MailThread(models.AbstractModel): # Bounce regex # Typical form of bounce is bounce_alias-128-crm.lead-34@domain # group(1) = the mail ID; group(2) = the model (if any); group(3) = the record ID - bounce_re = re.compile("%s-(\d+)-?([\w.]+)?-?(\d+)?" % re.escape(bounce_alias), re.UNICODE) + bounce_re = re.compile("%s\+(\d+)-?([\w.]+)?-?(\d+)?" % re.escape(bounce_alias), re.UNICODE) bounce_match = bounce_re.search(email_to) if bounce_match: bounced_model, bounced_thread_id = None, False