not create html in send_email if html isn't set

This commit is contained in:
Son 2021-11-04 14:27:33 +01:00
parent 80bbfb6f4b
commit f8b6b20dd8
1 changed files with 7 additions and 7 deletions

View File

@ -268,13 +268,13 @@ def send_email(
else:
smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)
msg = MIMEMultipart("alternative")
msg.attach(MIMEText(plaintext))
if not html:
LOG.d("Use plaintext as html")
html = plaintext.replace("\n", "<br>")
msg.attach(MIMEText(html, "html"))
if html:
msg = MIMEMultipart("alternative")
msg.attach(MIMEText(plaintext))
msg.attach(MIMEText(html, "html"))
else:
msg = Message()
msg.set_payload(plaintext)
msg[headers.SUBJECT] = subject
msg[headers.FROM] = f"{SUPPORT_NAME} <{SUPPORT_EMAIL}>"