From a2bbd49232178287e09bae39a4928db3eb2e5738 Mon Sep 17 00:00:00 2001 From: Son NK Date: Sun, 2 Feb 2020 18:53:26 +0700 Subject: [PATCH] handle the case reply_email not exist --- email_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/email_handler.py b/email_handler.py index 5f4f139c..eef24aaa 100644 --- a/email_handler.py +++ b/email_handler.py @@ -294,10 +294,14 @@ class MailHandler: # reply_email must end with EMAIL_DOMAIN if not reply_email.endswith(EMAIL_DOMAIN): - LOG.error(f"Reply email {reply_email} has wrong domain") + LOG.warning(f"Reply email {reply_email} has wrong domain") return "550 wrong reply email" forward_email = ForwardEmail.get_by(reply_email=reply_email) + if not forward_email: + LOG.warning(f"No such forward-email with {reply_email} as reply-email") + return "550 wrong reply email" + alias: str = forward_email.gen_email.email alias_domain = alias[alias.find("@") + 1 :]