From e2f0a72ab768bcc91fa90147e3c903e892c9b2bc Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Thu, 26 Nov 2020 09:49:03 +0100 Subject: [PATCH] log headers in case a contact email is skipped --- email_handler.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/email_handler.py b/email_handler.py index fae42ca6..10b062f9 100644 --- a/email_handler.py +++ b/email_handler.py @@ -258,8 +258,8 @@ def replace_header_when_forward(msg: Message, alias: Alias, header: str): Replace CC or To header by Reply emails in forward phase """ new_addrs: [str] = [] - - for contact_name, contact_email in getaddresses(msg.get_all(header, [])): + headers = msg.get_all(header, []) + for contact_name, contact_email in getaddresses(headers): # convert back to original then parse again to make sure contact_name is unicode addr = formataddr((contact_name, contact_email)) contact_name, contact = parseaddr_unicode(addr) @@ -270,10 +270,7 @@ def replace_header_when_forward(msg: Message, alias: Alias, header: str): continue if not is_valid_email(contact_email): - LOG.exception( - "invalid contact email %s. Skip", - contact_email, - ) + LOG.exception("invalid contact email %s. %s. Skip", contact_email, headers) continue contact = Contact.get_by(alias_id=alias.id, website_email=contact_email)