From f8b6b20dd8d0e1b585660b8154707f09b50efcfc Mon Sep 17 00:00:00 2001 From: Son Date: Thu, 4 Nov 2021 14:27:33 +0100 Subject: [PATCH] not create html in send_email if html isn't set --- app/email_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/email_utils.py b/app/email_utils.py index 5a78488a..c3db0be1 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -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", "
") - 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}>"