Skip to content

Commit

Permalink
fix: fall back to regex validation whenever verifymail can't validate
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-mih committed Nov 28, 2024
1 parent 4963fa5 commit 9f357aa
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions services/email-validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6147,20 +6147,18 @@ async def _validate_using_verify_mail(email: str):

if response.status_code != http.HTTPStatus.OK:
logger.error(response.text)
logger.error(response.status_code)
return False

return not response.json()["disposable"]


async def is_valid_email(email: str):
try:
return await _validate_using_verify_mail(email)
except Exception as exp:
logger.error(exp)
logger.warning(
f"Failed querying Verify Mail, defaulting to regex. Email: {email}"
)
result = await _validate_using_verify_mail(email)
if not result:
logger.warning("Falling back to email validation using regex catalog")
return bool(re.fullmatch(email_regex, email))
return result


@trace("Verify email domain")
Expand Down

0 comments on commit 9f357aa

Please sign in to comment.