From dcd116f11a13732b6d774ffa771e33d0e5d83acd Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 25 Nov 2020 17:50:25 +0100 Subject: [PATCH] use mail_from as fallback when contact_email is not valid --- email_handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/email_handler.py b/email_handler.py index 63145db3..fae42ca6 100644 --- a/email_handler.py +++ b/email_handler.py @@ -169,7 +169,7 @@ def get_or_create_contact( contact_from_header = str(contact_from_header) contact_name, contact_email = parseaddr_unicode(contact_from_header) - if not contact_email: + if not is_valid_email(contact_email): # From header is wrongly formatted, try with mail_from if mail_from and mail_from != "<>": LOG.warning( @@ -179,7 +179,7 @@ def get_or_create_contact( ) _, contact_email = parseaddr_unicode(mail_from) - if contact_email and not is_valid_email(contact_email): + if not is_valid_email(contact_email): LOG.exception( "invalid contact email %s. Parse from %s %s", contact_email, @@ -237,7 +237,7 @@ def get_or_create_contact( mail_from=mail_from, from_header=contact_from_header, reply_email=generate_reply_email(contact_email) - if contact_email + if is_valid_email(contact_email) else NOREPLY, ) if not contact_email: