From 3063fee47263d54fe130421095287c3d3665d16a Mon Sep 17 00:00:00 2001 From: Son NK Date: Sun, 26 Apr 2020 10:41:24 +0200 Subject: [PATCH] Use alias name in reply phase --- email_handler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/email_handler.py b/email_handler.py index a9201521..dd6f90c2 100644 --- a/email_handler.py +++ b/email_handler.py @@ -513,7 +513,12 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str delete_header(msg, "Received") # make the email comes from alias - add_or_replace_header(msg, "From", alias.email) + if alias.name: + LOG.d("Put alias name in from header") + from_header = formataddr((alias.name, alias.email)) + else: + from_header = alias.email + add_or_replace_header(msg, "From", from_header) # some email providers like ProtonMail adds automatically the Reply-To field # make sure to delete it