From 814329c55adbcd439d2412b2e4df247a7b633b28 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 9 Jul 2021 10:41:39 +0100 Subject: [PATCH] [FIX] mail_tracking: reduce spammy score Fix https://github.com/OCA/social/issues/701, following idea from https://kb.mailwizz.com/articles/low-score-in-spamassassin-because-of-the-rand_mktg_header-rule/ to avoid matching the regexp explained in https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7888#c5 @Tecnativa TT29674 --- mail_tracking/__manifest__.py | 2 +- mail_tracking/models/ir_mail_server.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mail_tracking/__manifest__.py b/mail_tracking/__manifest__.py index f5a65a5..456d656 100644 --- a/mail_tracking/__manifest__.py +++ b/mail_tracking/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Email tracking", "summary": "Email tracking system for all mails sent", - "version": "14.0.1.0.0", + "version": "14.0.1.0.1", "category": "Social Network", "website": "https://github.com/OCA/social", "author": ("Tecnativa, " "Odoo Community Association (OCA)"), diff --git a/mail_tracking/models/ir_mail_server.py b/mail_tracking/models/ir_mail_server.py index 769b6bd..3e610bd 100644 --- a/mail_tracking/models/ir_mail_server.py +++ b/mail_tracking/models/ir_mail_server.py @@ -14,7 +14,7 @@ class IrMailServer(models.Model): """Allow other addons to add its own tracking SMTP headers""" headers = headers or {} headers["X-Odoo-Database"] = getattr(threading.currentThread(), "dbname", None) - headers["X-Odoo-Tracking-ID"] = tracking_email_id + headers["X-Odoo-MailTracking-ID"] = tracking_email_id return headers def _tracking_email_id_body_get(self, body): @@ -64,9 +64,16 @@ class IrMailServer(models.Model): return msg def _tracking_email_get(self, message): - tracking_email_id = False - if message.get("X-Odoo-Tracking-ID", "").isdigit(): - tracking_email_id = int(message["X-Odoo-Tracking-ID"]) + try: + tracking_email_id = int( + message.get( + "X-Odoo-MailTracking-ID", + # Deprecated tracking header, kept as fallback + message["X-Odoo-Tracking-ID"], + ) + ) + except (TypeError, ValueError, KeyError): + tracking_email_id = False return self.env["mail.tracking.email"].browse(tracking_email_id) def _smtp_server_get(self, mail_server_id, smtp_server):