From 60a1f48e6ed9c595f9d45c33ac51fd9d6520a1b6 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 25 May 2021 17:59:09 +0200 Subject: [PATCH] take into account BOUNCE_PREFIX_FOR_REPLY_PHASE when handling bounces --- email_handler.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/email_handler.py b/email_handler.py index d43d815c..dea0fdce 100644 --- a/email_handler.py +++ b/email_handler.py @@ -1575,11 +1575,22 @@ def handle(envelope: Envelope) -> str: handle_transactional_bounce(envelope, rcpt_tos[0]) return "250 bounce handled" + # whether this is a bounce report + is_bounce = False + if ( len(rcpt_tos) == 1 and rcpt_tos[0].startswith(BOUNCE_PREFIX) and rcpt_tos[0].endswith(BOUNCE_SUFFIX) ): + is_bounce = True + + if len(rcpt_tos) == 1 and rcpt_tos[0].startswith( + f"{BOUNCE_PREFIX_FOR_REPLY_PHASE}+" + ): + is_bounce = True + + if is_bounce: return handle_bounce(envelope, rcpt_tos[0], msg) # Whether it's necessary to apply greylisting