Add Message-Id header to emails
authorStephen Frost <sfrost@snowman.net>
Mon, 13 Jan 2014 03:49:41 +0000 (22:49 -0500)
committerStephen Frost <sfrost@snowman.net>
Mon, 13 Jan 2014 03:49:41 +0000 (22:49 -0500)
The previous code, which was submitting locally, apparently didn't
need to provide a Message-Id header.  However, now that we're
directly submitting to a remote system, we need to make sure that
a Message-Id header exists or the emails will get bounced.

In addition, the Python docs for this module state that Message-Id
is really one of the required fields anyway.  It's unclear how many
real bugs we lost because of this, but I got involved when there
was complaining on IRC that a bug submitted didn't show up on the
-bugs list.

In case folks are wondering why I'm committing/pushing this (or how),
I've already fixed this on wrigleys (thanks to Andrew Gierth for
helping me debug and test the changes) and subsequently gave myself
access to this repo, to get this commit in, before anyone else
commits and overwrites my local hacks and breaks the bugs form again.

pgweb/mailqueue/util.py

index d4d079f0ab374bd60db8e5be42580d30df27fe24..3a35c41a7702af56752025ef2c8c715f2ec637df 100644 (file)
@@ -2,6 +2,7 @@ from email.mime.text import MIMEText
 from email.mime.multipart import MIMEMultipart
 from email.mime.nonmultipart import MIMENonMultipart
 from email.Utils import formatdate
+from email.Utils import make_msgid
 from email import encoders
 
 from models import QueuedMail
@@ -16,6 +17,7 @@ def send_simple_mail(sender, receiver, subject, msgtxt, attachments=None, userge
        msg['To'] = receiver
        msg['From'] = sender
        msg['Date'] = formatdate(localtime=True)
+       msg['Message-ID'] = make_msgid()
 
        msg.attach(MIMEText(msgtxt, _charset='utf-8'))