markup: add send_error_email()

This commit is contained in:
2019-10-31 11:50:13 -07:00
parent e0faeed020
commit b873327bee

View File

@ -47,6 +47,7 @@ ProCatalog Markup Bot
def reply(frm, subj, xls_path, pdf_path): def reply(frm, subj, xls_path, pdf_path):
msg = EmailMessage() msg = EmailMessage()
msg.set_content(body_ok) msg.set_content(body_ok)
subj = f'Re: {subj}'
with open(xls_path, 'rb') as fp: with open(xls_path, 'rb') as fp:
msg.add_attachment(fp.read(), msg.add_attachment(fp.read(),
@ -66,23 +67,28 @@ def reply(frm, subj, xls_path, pdf_path):
def reply_missing(frm, subj): def reply_missing(frm, subj):
msg = EmailMessage() msg = EmailMessage()
msg.set_content(body_missing) msg.set_content(body_missing)
subj = f'Re: {subj}'
send(frm, subj, msg) send(frm, subj, msg)
def reply_no_matches(frm, subj): def reply_no_matches(frm, subj):
msg = EmailMessage() msg = EmailMessage()
msg.set_content(body_no_matches) msg.set_content(body_no_matches)
subj = f'Re: {subj}'
send(frm, subj, msg) send(frm, subj, msg)
def send_error_email(subj, einfo):
msg = EmailMessage()
msg.set_content(einfo)
send('error@procatalog.io', subj, msg)
def send(frm, subj, msg): def send(frm, subj, msg):
msg['From'] = 'Keen ProCatalog Markup Bot <support@procatalog.io>' msg['From'] = 'Keen ProCatalog Markup Bot <support@procatalog.io>'
msg['To'] = frm msg['To'] = frm
msg['Bcc'] = 'alx-markup@procatalog.io' msg['Bcc'] = 'alx-markup@procatalog.io'
subj = f'Re: {subj}'
msg['Subject'] = Header(subj).encode() msg['Subject'] = Header(subj).encode()
msg['Message-ID'] = msgid() msg['Message-ID'] = msgid()
msg['Date'] = formatdate() msg['Date'] = formatdate()