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