force convert header to string if needed

This commit is contained in:
Son NK 2020-06-10 09:34:58 +02:00
parent c847d205b6
commit c36870daa8
1 changed files with 3 additions and 2 deletions

View File

@ -305,9 +305,10 @@ def generate_reply_email():
def should_append_alias(msg: Message, address: str):
"""whether an alias should be appended to TO header in message"""
if msg["To"] and address.lower() in msg["To"].lower():
# # force convert header to string, sometimes addrs is Header object
if msg["To"] and address.lower() in str(msg["To"]).lower():
return False
if msg["Cc"] and address.lower() in msg["Cc"].lower():
if msg["Cc"] and address.lower() in str(msg["Cc"]).lower():
return False
return True