do not use email_validator in get_email_domain_part()

This commit is contained in:
Son Nguyen Kim 2021-09-27 12:13:41 +02:00
parent 3ad961bfb9
commit 8301015afd
2 changed files with 5 additions and 6 deletions

View File

@ -128,7 +128,6 @@ def try_auto_create_via_domain(address: str) -> Optional[Alias]:
# check if alias is custom-domain alias and if the custom-domain has catch-all enabled
alias_domain = get_email_domain_part(address)
custom_domain: CustomDomain = CustomDomain.get_by(domain=alias_domain)
alias_note = ""
if not custom_domain:
return None

View File

@ -404,10 +404,8 @@ def get_email_domain_part(address):
Get the domain part from email
ab@cd.com -> cd.com
"""
r: ValidatedEmail = validate_email(
address, check_deliverability=False, allow_smtputf8=False
)
return r.domain
address = sanitize_email(address)
return address[address.find("@") + 1 :]
# headers used to DKIM sign in order of preference
@ -532,7 +530,9 @@ def email_can_be_used_as_mailbox(email_address: str) -> bool:
- a disposable domain
"""
try:
domain = get_email_domain_part(email_address)
domain = validate_email(
email_address, check_deliverability=False, allow_smtputf8=False
).domain
except EmailNotValidError:
return False