From 7598a167d057f136daedbd8e754e1d0f71f798ef Mon Sep 17 00:00:00 2001 From: Son NK Date: Tue, 11 Feb 2020 22:58:30 +0700 Subject: [PATCH] Improve emails that inform unauthorized user --- app/email_utils.py | 2 +- email_handler.py | 9 +++++++-- .../send-from-alias-from-unknown-sender.txt | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 templates/emails/transactional/send-from-alias-from-unknown-sender.txt diff --git a/app/email_utils.py b/app/email_utils.py index 096ce13d..8a13b127 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -186,7 +186,7 @@ def send_email(to_email, subject, plaintext, html): msg["To"] = to_email msg.set_content(plaintext) - if html is not None: + if html: msg.add_alternative(html, subtype="html") msg_id_header = make_msgid() diff --git a/email_handler.py b/email_handler.py index afe66159..a5c63e4a 100644 --- a/email_handler.py +++ b/email_handler.py @@ -348,10 +348,15 @@ class MailHandler: ), ) + # Notify sender that they cannot send emails to this address send_email( envelope.mail_from, - f"Your email ({envelope.mail_from}) is not allowed to send email to {reply_email}", - "", + f"Your email ({envelope.mail_from}) is not allowed to send emails to {reply_email}", + render( + "transactional/send-from-alias-from-unknown-sender.txt", + sender=envelope.mail_from, + reply_email=reply_email, + ), "", ) diff --git a/templates/emails/transactional/send-from-alias-from-unknown-sender.txt b/templates/emails/transactional/send-from-alias-from-unknown-sender.txt new file mode 100644 index 00000000..992ebaca --- /dev/null +++ b/templates/emails/transactional/send-from-alias-from-unknown-sender.txt @@ -0,0 +1,12 @@ +Hi, + +This is an automated email from SimpleLogin. + +We have recorded an attempt to send an email from your email ({{sender}}) to {{reply_email}}. + +{{reply_email}} is a special email address that only receive emails from its authorized user. + +If you have any question, you can contact us by replying to this email or consult our website at https://simplelogin.io. + +Regards, +SimpleLogin team.