From 59c189957f8ef2422437318591cfde274e230e0b Mon Sep 17 00:00:00 2001 From: Son Nguyen Kim Date: Thu, 20 Apr 2023 12:43:43 +0200 Subject: [PATCH] fix the E501 check (#1702) --- email_handler.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/email_handler.py b/email_handler.py index 031db76b..93f3f0e4 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1020,12 +1020,13 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str): reply_email = rcpt_to reply_domain = get_email_domain_part(reply_email) - # reply_email must end with EMAIL_DOMAIN - if not reply_email.endswith(EMAIL_DOMAIN) or not SLDomain.get_by( - domain=reply_domain - ): - LOG.w(f"Reply email {reply_email} has wrong domain") - return False, status.E501 + + # reply_email must end with EMAIL_DOMAIN or a domain that can be used as reverse alias domain + if not reply_email.endswith(EMAIL_DOMAIN): + sl_domain: SLDomain = SLDomain.get_by(domain=reply_domain) + if sl_domain is None or not sl_domain.use_as_reverse_alias: + LOG.w(f"Reply email {reply_email} has wrong domain") + return False, status.E501 # handle case where reply email is generated with non-allowed char reply_email = normalize_reply_email(reply_email)