API (AWS)

email-validator: Validate Email Addresses

jasonshin 2022. 1. 6. 15:26

https://pypi.org/project/email-validator/

 

email-validator

A robust email syntax and deliverability validation library for Python 2.x/3.x.

pypi.org

설치 :

pip install email-validator

 

 

코드 :

from email_validator import validate_email, EmailNotValidError

email = "my+address@mydomain.tld"

try:
  # Validate.
  valid = validate_email(email)

  # Update with the normalized form.
  email = valid.email
except EmailNotValidError as e:
  # email is not valid, exception message is human-readable
  print(str(e))
from email_validator import validate_email, caching_resolver

resolver = caching_resolver(timeout=10)

while True:
  valid = validate_email(email, dns_resolver=resolver)
반응형