do not create contact with invalid email in get_or_create_contact()
This commit is contained in:
parent
609d59d23f
commit
dfcb74dc87
|
@ -104,6 +104,7 @@ from app.email_utils import (
|
||||||
generate_reply_email,
|
generate_reply_email,
|
||||||
is_reply_email,
|
is_reply_email,
|
||||||
normalize_reply_email,
|
normalize_reply_email,
|
||||||
|
is_valid_email,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.greylisting import greylisting_needed
|
from app.greylisting import greylisting_needed
|
||||||
|
@ -178,6 +179,16 @@ def get_or_create_contact(
|
||||||
)
|
)
|
||||||
_, contact_email = parseaddr_unicode(mail_from)
|
_, contact_email = parseaddr_unicode(mail_from)
|
||||||
|
|
||||||
|
if contact_email and not is_valid_email(contact_email):
|
||||||
|
LOG.exception(
|
||||||
|
"invalid contact email %s. Parse from %s %s",
|
||||||
|
contact_email,
|
||||||
|
contact_from_header,
|
||||||
|
mail_from,
|
||||||
|
)
|
||||||
|
# either reuse a contact with empty email or create a new contact with empty email
|
||||||
|
contact_email = ""
|
||||||
|
|
||||||
contact = Contact.get_by(alias_id=alias.id, website_email=contact_email)
|
contact = Contact.get_by(alias_id=alias.id, website_email=contact_email)
|
||||||
if contact:
|
if contact:
|
||||||
if contact.name != contact_name:
|
if contact.name != contact_name:
|
||||||
|
|
Loading…
Reference in New Issue