From b47d95226d07c8e0062c39b8ad5d7dbe2ee46c9b Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 10 Jun 2020 12:18:39 +0200 Subject: [PATCH] generate html from plaintext if not set --- app/email_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/email_utils.py b/app/email_utils.py index 52f436bc..9f5a614e 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -200,8 +200,10 @@ def send_email(to_email, subject, plaintext, html=None): msg = MIMEMultipart("alternative") msg.attach(MIMEText(plaintext, "text")) - if html: - msg.attach(MIMEText(html, "html")) + + if not html: + html = plaintext.replace("\n", "
") + msg.attach(MIMEText(html, "html")) msg["Subject"] = subject msg["From"] = f"{SUPPORT_NAME} <{SUPPORT_EMAIL}>"