Skip to content
Browse files

[FIX] mass_mailing: can unsubscribe in multidomain

The `unsubscribe` feature of mass mailings repose on having a link with
HREF attribute `/unsubscribe_from_list` inside the mail message.

When the mass mailing is sent:

- relative URL are replaced by absolute URL (`/unsubscribe_from_list` is
  replaced by `{system parameter web.base.url}/unsubscribe_from_list`)

- `{system parameter web.base.url}/unsubscribe_from_list` is replaced by
  the real mass mailing link containing info that will be used to
  unsubscribe the user.

But there was an issue in the case of multiple domain, if this scenario

- system parameter web.base.url is http://domain1
- a user use "Test" button on a mass mailing
- system parameter web.base.url becomes http://domain2
- the mass mailing is sent

The unsubscribe link is broken, this is because the implementation of
"Test Mailing" feature would update the mass mailing with absolute
links, so if the domain change, we the `unsubscribe` link will no longer
be found and replaced into the source.

closes #42373

closes #42852

X-original-commit: fccf20b
Signed-off-by: Nicolas Lempereur (nle) <>
  • Loading branch information
nle-odoo committed Dec 26, 2019
1 parent b0c4a98 commit e5311b9ddb89b223486a8e1050e5c7a2d017ea07
Showing with 2 additions and 2 deletions.
  1. +2 −2 addons/mass_mailing/wizard/
@@ -20,13 +20,13 @@ def send_mail_test(self):
test_emails = tools.email_split(self.email_to)
for test_mail in test_emails:
# Convert links in absolute URLs before the application of the shortener
mailing.write({'body_html': self.env['mail.thread']._replace_local_links(mailing.body_html)})
body = self.env['mail.thread']._replace_local_links(mailing.body_html)
mail_values = {
'email_from': mailing.email_from,
'reply_to': mailing.reply_to,
'email_to': test_mail,
'body_html': tools.html_sanitize(mailing.body_html, sanitize_attributes=True, sanitize_style=True, strip_classes=True),
'body_html': tools.html_sanitize(body, sanitize_attributes=True, sanitize_style=True, strip_classes=True),
'notification': True,
'attachment_ids': [(4, for attachment in mailing.attachment_ids],

0 comments on commit e5311b9

Please sign in to comment.
You can’t perform that action at this time.