From 3d9594cfaae9980355514796965eed72ac432579 Mon Sep 17 00:00:00 2001 From: antar37 Date: Thu, 20 Mar 2025 12:43:56 -0600 Subject: [PATCH] Update mail.py using make_msgid to create a well-formed message-ID. The lack of brackets causes gmail to reject the message-ID --- cps/tasks/mail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cps/tasks/mail.py b/cps/tasks/mail.py index f332e267..49cd913f 100644 --- a/cps/tasks/mail.py +++ b/cps/tasks/mail.py @@ -25,7 +25,7 @@ import mimetypes from io import StringIO from email.message import EmailMessage -from email.utils import formatdate, parseaddr +from email.utils import formatdate, parseaddr, make_msgid from email.generator import Generator from flask_babel import lazy_gettext as N_ @@ -142,7 +142,7 @@ class TaskEmail(CalibreTask): message['To'] = self.recipient message['Subject'] = self.subject message['Date'] = formatdate(localtime=True) - message['Message-Id'] = "{}@{}".format(uuid.uuid4(), self.get_msgid_domain()) + message['Message-ID'] = make_msgid(domain=self.get_msgid_domain()) message.set_content(self.text.encode('UTF-8'), "text", "plain") if self.attachment: data = self._get_attachment(self.filepath, self.attachment)