smtp: add Date header as required for rfc5322

this prevents from bad header classifications in mail filters
This commit is contained in:
Matthias Maennich 2011-10-11 22:16:53 +02:00
parent 983a3a76c5
commit 7519a43d8f

View File

@ -18,11 +18,13 @@ def create_mail(from_, to, subject, text=None, attachment_data=None,
assert text or attachment_data assert text or attachment_data
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.utils import formatdate
outer = MIMEMultipart() outer = MIMEMultipart()
outer['Subject'] = subject outer['Subject'] = subject
outer['To'] = to outer['To'] = to
outer['From'] = from_ outer['From'] = from_
outer['Date'] = formatdate()
outer.preamble = 'You will not see this in a MIME-aware mail reader.\n' outer.preamble = 'You will not see this in a MIME-aware mail reader.\n'
if text is not None: if text is not None: