Pārlūkot izejas kodu

Improve emails that inform unauthorized user

Son NK 5 gadi atpakaļ
vecāks
revīzija
7598a167d0

+ 1 - 1
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()

+ 7 - 2
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,
+                ),
                 "",
             )
 

+ 12 - 0
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.