From 82154ec858752d4ddabf8835bbc1182359dc19cc Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Mon, 15 Mar 2021 19:55:22 +0100 Subject: [PATCH] ignore email sent from a reverse-alias --- email_handler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/email_handler.py b/email_handler.py index b7b618cb..0c314537 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1529,6 +1529,15 @@ def handle(envelope: Envelope) -> str: envelope.mail_from = mail_from envelope.rcpt_tos = rcpt_tos + contact = Contact.get_by(reply_email=mail_from) + if contact: + LOG.exception( + "email can't be sent from a reverse-alias alias:%s, contact email:%s", + contact.alias, + contact.website_email, + ) + return "250 email can't be sent from a reverse-alias" + # unsubscribe request if UNSUBSCRIBER and rcpt_tos == [UNSUBSCRIBER]: LOG.d("Handle unsubscribe request from %s", mail_from)