On Jun 28, 2020, at 4:22 PM, Mark Sapiro <mark@msapiro.net> wrote:
If I'm reading the above correctly, it appears that there is a message in the archive database whose message_id value is 'BYAPR02MB5976132151FF19510269C44CB3940@BYAPR02MB5976.namprd02.prod.outlook.com>'. The trailing '>' is causing HyperKitty's Email.as_message() method to try to set a value of '<BYAPR02MB5976132151FF19510269C44CB3940@BYAPR02MB5976.namprd02.prod.outlook.com>>'.
Or maybe there's leading white space in the value, or both.
Try the following patch.
--- a/hyperkitty/models/email.py +++ b/hyperkitty/models/email.py @@ -24,7 +24,7 @@ import logging import os import re from email.message import EmailMessage -from email.utils import formataddr +from email.utils import formataddr, make_msgid
from django.conf import settings from django.db import IntegrityError, models @@ -175,7 +175,12 @@ class Email(models.Model): header_date = self.date.astimezone(tz).replace(microsecond=0) # Date format: http://tools.ietf.org/html/rfc5322#section-3.3 msg["Date"] = header_date.strftime("%a, %d %b %Y %H:%M:%S %z") - msg["Message-ID"] = "<%s>" % self.message_id + try: + msg["Message-ID"] = "<%s>" % re.sub('[<>\s]', '', + self.message_id) + except: + msg["Message-ID"] = make_msgid() if self.in_reply_to: msg["In-Reply-To"] = unfold(self.in_reply_to)
The patch does not apply cleanly against /usr/lib/python3/dist-packages/hyperkitty/models/email.py patching file email.py patch: **** malformed patch at line 4: import os I am assuming that this is because I am running the Ubuntu packages, which are a year down-rev: Mailman Core Version GNU Mailman 3.2.2 (La Villa Strangiato) Mailman Core API Version 3.0 Mailman Core Python Version 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0] - Mark ----- mark@pdc-racing.net | 408-348-2878