Forráskód Böngészése

alert user when spf fails

Son NK 5 éve
szülő
commit
178515dbde

+ 6 - 0
app/config.py

@@ -255,6 +255,8 @@ APPLE_API_SECRET = os.environ.get("APPLE_API_SECRET")
 # for Mac App
 MACAPP_APPLE_API_SECRET = os.environ.get("MACAPP_APPLE_API_SECRET")
 
+# <<<<< ALERT EMAIL >>>>
+
 # maximal number of alerts that can be sent to the same email in 24h
 MAX_ALERT_24H = 4
 
@@ -266,3 +268,7 @@ ALERT_BOUNCE_EMAIL = "bounce"
 
 # When a forwarding email is detected as spam
 ALERT_SPAM_EMAIL = "spam"
+
+ALERT_SPF = "spf"
+
+# <<<<< END ALERT EMAIL >>>>

+ 2 - 2
app/dashboard/templates/dashboard/mailbox_detail.html

@@ -108,9 +108,9 @@
 
       <hr>
       <h2 class="h4">Advanced Options</h2>
-    
+
       {% if spf_available %}
-        <div class="card">
+        <div class="card" id="spf">
           <form method="post">
             <input type="hidden" name="form-name" value="force-spf">
 

+ 22 - 1
email_handler.py

@@ -59,6 +59,7 @@ from app.config import (
     ALERT_REVERSE_ALIAS_UNKNOWN_MAILBOX,
     ALERT_BOUNCE_EMAIL,
     ALERT_SPAM_EMAIL,
+    ALERT_SPF,
 )
 from app.email_utils import (
     send_email,
@@ -493,7 +494,27 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str
                         "SPF fail for mailbox %s, reason %s, failed IP %s",
                         mailbox_email,
                         r[0],
-                        msg[_IP_HEADER],
+                        ip,
+                    )
+                    send_email_with_rate_control(
+                        user,
+                        ALERT_SPF,
+                        mailbox_email,
+                        f"SimpleLogin Alert: attempt to send emails from your alias {alias.email} from unknown IP Address",
+                        render(
+                            "transactional/spf-fail.txt",
+                            name=user.name,
+                            alias=alias.email,
+                            ip=ip,
+                            mailbox_url=URL + f"/dashboard/mailbox/{mailb.id}#spf",
+                        ),
+                        render(
+                            "transactional/spf-fail.html",
+                            name=user.name,
+                            alias=alias.email,
+                            ip=ip,
+                            mailbox_url=URL + f"/dashboard/mailbox/{mailb.id}#spf",
+                        ),
                     )
                     return False, "451 SL E11"
         else: