From ac1a6f5613543219eae8cb4c7deb2deb77729098 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 25 Nov 2020 15:21:01 +0100 Subject: [PATCH] skip invalid contact in replace_header_when_forward() --- email_handler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/email_handler.py b/email_handler.py index 93fb2aae..63145db3 100644 --- a/email_handler.py +++ b/email_handler.py @@ -269,6 +269,13 @@ def replace_header_when_forward(msg: Message, alias: Alias, header: str): new_addrs.append(addr) continue + if not is_valid_email(contact_email): + LOG.exception( + "invalid contact email %s. Skip", + contact_email, + ) + continue + contact = Contact.get_by(alias_id=alias.id, website_email=contact_email) if contact: # update the contact name if needed