Skip to content

Commit 6287681

Browse files
committed
Define a default timeout for email deliverability validation (15s)
1 parent f82f628 commit 6287681

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

email_validator/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
DOT_ATOM_TEXT = DOT_ATOM_TEXT.decode("ascii")
4040
ATEXT_HOSTNAME = ATEXT_HOSTNAME.decode("ascii")
4141

42+
DEFAULT_TIMEOUT = 15 # secs
43+
4244
class EmailNotValidError(ValueError):
4345
"""Parent class of all exceptions raised by this module."""
4446
pass
@@ -56,7 +58,7 @@ def validate_email(
5658
allow_smtputf8=True,
5759
allow_empty_local=False,
5860
check_deliverability=True,
59-
timeout=0):
61+
timeout=DEFAULT_TIMEOUT):
6062

6163
"""Validates an email address, raising an EmailNotValidError if the address is not valid or returning a dict of information
6264
when the address is valid. The email argument can be a str or a bytes instance, but if bytes it must be ASCII-only."""
@@ -234,7 +236,7 @@ def validate_email_domain_part(domain):
234236
"domain_i18n": domain_i18n,
235237
}
236238

237-
def validate_email_deliverability(domain, domain_i18n, timeout=0):
239+
def validate_email_deliverability(domain, domain_i18n, timeout=DEFAULT_TIMEOUT):
238240
# Check that the domain resolves to an MX record. If there is no MX record,
239241
# try an A or AAAA record which is a deprecated fallback for deliverability.
240242

0 commit comments

Comments
 (0)