diff --git a/app/email_utils.py b/app/email_utils.py index 6b43dd72..69a94654 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -1078,7 +1078,9 @@ def generate_reply_email(contact_email: str, user: User) -> str: contact_email = convert_to_id(contact_email) contact_email = sanitize_email(contact_email) contact_email = contact_email[:45] - contact_email = contact_email.replace("@", ".at.") + # use _ instead of . to avoid AC_FROM_MANY_DOTS SpamAssassin rule + contact_email = contact_email.replace("@", "_at_") + contact_email = contact_email.replace(".", "_") contact_email = convert_to_alphanumeric(contact_email) # not use while to avoid infinite loop diff --git a/tests/test_email_utils.py b/tests/test_email_utils.py index 94b57e0b..b6a4f2f8 100644 --- a/tests/test_email_utils.py +++ b/tests/test_email_utils.py @@ -500,18 +500,18 @@ def test_generate_reply_email_include_sender_in_reverse_alias(flask_client): user.include_sender_in_reverse_alias = True reply_email = generate_reply_email("test@example.org", user) - assert reply_email.startswith("test.at.example.org") + assert reply_email.startswith("test_at_example_org") assert reply_email.endswith(EMAIL_DOMAIN) reply_email = generate_reply_email("", user) assert reply_email.endswith(EMAIL_DOMAIN) reply_email = generate_reply_email("👌汉字@example.org", user) - assert reply_email.startswith("yizi.at.example.org") + assert reply_email.startswith("yizi_at_example_org") # make sure reply_email only contain lowercase reply_email = generate_reply_email("TEST@example.org", user) - assert reply_email.startswith("test.at.example.org") + assert reply_email.startswith("test_at_example_org") def test_normalize_reply_email(flask_client):