From 2efe8cd160791ccbe29b63606175ad9dadff7fa7 Mon Sep 17 00:00:00 2001 From: Son NK Date: Mon, 10 Feb 2020 23:24:14 +0700 Subject: [PATCH] take into account mailbox in reply phase: check the reply must come from mailbox --- email_handler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/email_handler.py b/email_handler.py index 1ad76f24..672adbeb 100644 --- a/email_handler.py +++ b/email_handler.py @@ -313,13 +313,18 @@ class MailHandler: if not CustomDomain.get_by(domain=alias_domain): return "550 alias unknown by SimpleLogin" - user_email = forward_email.gen_email.user.email - if envelope.mail_from.lower() != user_email.lower(): + gen_email = forward_email.gen_email + if gen_email.mailbox_id: + mailbox_email = gen_email.mailbox.email + else: + mailbox_email = gen_email.user.email + + if envelope.mail_from.lower() != mailbox_email.lower(): LOG.warning( f"Reply email can only be used by user email. Actual mail_from: %s. msg from header: %s, User email %s. reply_email %s", envelope.mail_from, msg["From"], - user_email, + mailbox_email, reply_email, )