diff --git a/addons/mass_mailing/models/mail_mail.py b/addons/mass_mailing/models/mail_mail.py index 651d8f07729..c2775ad019b 100644 --- a/addons/mass_mailing/models/mail_mail.py +++ b/addons/mass_mailing/models/mail_mail.py @@ -21,6 +21,7 @@ import urlparse import werkzeug.urls +import re from openerp.tools.translate import _ from openerp import tools @@ -80,6 +81,14 @@ class MailMail(osv.Model): base = "" % domain body = tools.append_content_to_html(base, body, plaintext=False, container_tag='div') + # resolve relative image url to absolute for outlook.com + def _sub_relative2absolute(match): + return match.group(1) + urlparse.urljoin(domain, match.group(2)) + # Regex: https://regex101.com/r/aE8uG5/3 + body = re.sub('(]*\ssrc=["\'])(/[^/][^"\']+)', _sub_relative2absolute, body) + # Regex: https://regex101.com/r/kT3lD5/2 + body = re.sub(r'(<[^>]+\bstyle=["\'][^"\']+\burl\([\'"]?)(/[^/\'"][^\'")]+)', _sub_relative2absolute, body) + # generate tracking URL if mail.statistics_ids: tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context)