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)