[FIX][IMP] mail, mass_mailing: improve making of Return-Path alias

Previously Return-Path were composed using bounce_alias-<mail_id>-<model>-
<thread_id> . However this may lead to return adresses not supported by
the incoming mail server. We now form the bounce alias using bounce_alis+
<mail_id>-<model>-<thread_id>. 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.
This commit is contained in:
Thibault Delavallée
2016-09-01 12:57:05 +02:00
parent 6aebdc2ab6
commit 0843df213c
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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))
+1 -1
View File
@@ -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