Skip to content

Commit 65b2744

Browse files
committed
Recommend that check_deliverability be set to False for validation on login pages
1 parent b87f8d3 commit 65b2744

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,27 @@ account in your application, you might do this:
6969
from email_validator import validate_email, EmailNotValidError
7070

7171
72+
is_new_account = True # False for login pages
7273

7374
try:
74-
# Validate & take the normalized form of the email
75-
# address for all logic beyond this point (especially
75+
# Check that the email address is valid.
76+
validation = validate_email(email, check_deliverability=is_new_account)
77+
78+
# Take the normalized form of the email address
79+
# for all logic beyond this point (especially
7680
# before going to a database query where equality
77-
# does not take into account normalization).
78-
email = validate_email(email).email
81+
# may not take into account Unicode normalization).
82+
email = validation.email
7983
except EmailNotValidError as e:
80-
# email is not valid, exception message is human-readable
84+
# Email is not valid.
85+
# The exception message is human-readable.
8186
print(str(e))
8287
```
8388

8489
This validates the address and gives you its normalized form. You should
8590
**put the normalized form in your database** and always normalize before
86-
checking if an address is in your database.
87-
88-
The validator will accept internationalized email addresses, but not all
89-
mail systems can send email to an addresses with non-English characters in
90-
the *local* part of the address (before the @-sign). See the `allow_smtputf8`
91-
option below.
91+
checking if an address is in your database. When using this in a login form,
92+
set `check_deliverability` to `False` to avoid unnecessary DNS queries.
9293

9394
Usage
9495
-----
@@ -138,7 +139,7 @@ The `validate_email` function also accepts the following keyword arguments
138139
require the
139140
[SMTPUTF8](https://tools.ietf.org/html/rfc6531) extension.
140141

141-
`check_deliverability=True`: Set to `False` to skip the domain name MX DNS record check.
142+
`check_deliverability=True`: Set to `False` to skip the domain name MX DNS record check. It is recommended to pass `False` when performing validation for login pages since re-validation of the domain by querying DNS at every login is probably undesirable.
142143

143144
`allow_empty_local=False`: Set to `True` to allow an empty local part (i.e.
144145
`@example.com`), e.g. for validating Postfix aliases.

0 commit comments

Comments
 (0)