markup email handle encoded headers

This commit is contained in:
2019-10-30 15:46:23 -07:00
parent a1aff2cb99
commit 14003e9dc2
2 changed files with 13 additions and 4 deletions

View File

@ -5,6 +5,8 @@ import smtplib
from pathlib import Path
from mailbox import Maildir
from email.message import EmailMessage
from email.utils import formatdate
from email.header import Header, make_header
import logging
log = logging.getLogger(__name__)
@ -59,11 +61,14 @@ def send(frm, subj, msg):
msg['From'] = 'Keen ProCatalog Markup Bot <support@procatalog.io>'
msg['To'] = frm
msg['Bcc'] = 'alx-markup@procatalog.io'
msg['Subject'] = f'Re: {subj}'
subj = f'Re: {subj}'
msg['Subject'] = Header(subj).encode()
msg['Message-ID'] = msgid()
maildir = Maildir('/tmp/markup_submit_mail')
maildir.add(msg)
maildir.add(msg.as_bytes())
log.info(f'sending email to "{frm}": {subj}')