From 73555ad5240d3751993ec14982666726d745edb3 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 25 May 2021 17:58:45 +0200 Subject: [PATCH] generate mail_from during reply phase using BOUNCE_PREFIX_FOR_REPLY_PHASE --- email_handler.py | 7 +++++-- tests/test_email_utils.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/email_handler.py b/email_handler.py index fe8e9ebd..d43d815c 100644 --- a/email_handler.py +++ b/email_handler.py @@ -73,6 +73,7 @@ from app.config import ( TRANSACTIONAL_BOUNCE_PREFIX, TRANSACTIONAL_BOUNCE_SUFFIX, ENABLE_SPAM_ASSASSIN, + BOUNCE_PREFIX_FOR_REPLY_PHASE, ) from app.email.spam import get_spam_score from app.email_utils import ( @@ -951,10 +952,12 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str): if should_add_dkim_signature(alias_domain): add_dkim_signature(msg, alias_domain) + # generate a mail_from for VERP + verp_mail_from = f"{BOUNCE_PREFIX_FOR_REPLY_PHASE}+{email_log.id}+@{alias_domain}" + try: sl_sendmail( - # VERP - BOUNCE_EMAIL.format(email_log.id), + verp_mail_from, contact.website_email, msg, envelope.mail_options, diff --git a/tests/test_email_utils.py b/tests/test_email_utils.py index c1805b96..fcc848c8 100644 --- a/tests/test_email_utils.py +++ b/tests/test_email_utils.py @@ -718,4 +718,5 @@ def test_should_disable_bounce_consecutive_days(flask_client): def test_parse_id_from_bounce(): assert parse_id_from_bounce("bounces+1234+@local") == 1234 + assert parse_id_from_bounce("anything+1234+@local") == 1234 assert parse_id_from_bounce(BOUNCE_EMAIL.format(1234)) == 1234