[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:
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user