2020-09-11 14:25:19 +00:00
|
|
|
##########################################################################
|
|
|
|
#
|
|
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
|
|
#
|
2022-01-04 08:24:25 +00:00
|
|
|
# Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
2020-09-11 14:25:19 +00:00
|
|
|
# This software is released under the PostgreSQL Licence
|
|
|
|
#
|
|
|
|
##########################################################################
|
|
|
|
|
2021-07-05 07:25:40 +00:00
|
|
|
from email_validator import validate_email as email_validate, \
|
|
|
|
EmailNotValidError
|
|
|
|
import config
|
2020-09-11 14:25:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
def validate_email(email):
|
2021-07-05 07:25:40 +00:00
|
|
|
try:
|
|
|
|
# Validate.
|
|
|
|
valid = email_validate(
|
|
|
|
email, check_deliverability=config.CHECK_EMAIL_DELIVERABILITY)
|
2020-09-11 14:25:19 +00:00
|
|
|
|
2021-07-05 07:25:40 +00:00
|
|
|
# Update with the normalized form.
|
|
|
|
email = valid.email
|
|
|
|
return True
|
|
|
|
except EmailNotValidError as e:
|
|
|
|
# email is not valid, exception message is human-readable
|
|
|
|
print(str(e))
|
2020-09-11 14:25:19 +00:00
|
|
|
return False
|