From 30185a279820c4ddaf420db18d93623d6c99fa8e Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 18 Nov 2020 16:11:00 +0100 Subject: [PATCH] handle the case where reply_email is not ascii --- email_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/email_handler.py b/email_handler.py index 6aa1a48e..4b4715f0 100644 --- a/email_handler.py +++ b/email_handler.py @@ -118,7 +118,7 @@ from app.models import ( ) from app.pgp_utils import PGPException, sign_data_with_pgpy, sign_data from app.spamassassin_utils import SpamAssassin -from app.utils import random_string +from app.utils import random_string, convert_to_id from init_app import load_pgp_public_keys from server import create_app, create_light_app @@ -790,6 +790,10 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str): LOG.warning(f"Reply email {reply_email} has wrong domain") return False, "550 SL E2" + # handle case where reply email is generated with non-ascii char + if not reply_email.isascii(): + reply_email = convert_to_id(reply_email) + contact = Contact.get_by(reply_email=reply_email) if not contact: LOG.warning(f"No such forward-email with {reply_email} as reply-email")