generate mail_from during reply phase using BOUNCE_PREFIX_FOR_REPLY_PHASE

This commit is contained in:
Son NK 2021-05-25 17:58:45 +02:00
parent 2f96322977
commit 73555ad524
2 changed files with 6 additions and 2 deletions

View File

@ -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,

View File

@ -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