not create html in send_email if html isn't set
This commit is contained in:
parent
80bbfb6f4b
commit
f8b6b20dd8
|
@ -268,13 +268,13 @@ def send_email(
|
||||||
else:
|
else:
|
||||||
smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)
|
smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)
|
||||||
|
|
||||||
|
if html:
|
||||||
msg = MIMEMultipart("alternative")
|
msg = MIMEMultipart("alternative")
|
||||||
msg.attach(MIMEText(plaintext))
|
msg.attach(MIMEText(plaintext))
|
||||||
|
|
||||||
if not html:
|
|
||||||
LOG.d("Use plaintext as html")
|
|
||||||
html = plaintext.replace("\n", "<br>")
|
|
||||||
msg.attach(MIMEText(html, "html"))
|
msg.attach(MIMEText(html, "html"))
|
||||||
|
else:
|
||||||
|
msg = Message()
|
||||||
|
msg.set_payload(plaintext)
|
||||||
|
|
||||||
msg[headers.SUBJECT] = subject
|
msg[headers.SUBJECT] = subject
|
||||||
msg[headers.FROM] = f"{SUPPORT_NAME} <{SUPPORT_EMAIL}>"
|
msg[headers.FROM] = f"{SUPPORT_NAME} <{SUPPORT_EMAIL}>"
|
||||||
|
|
Loading…
Reference in a new issue