You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,13 @@
3
3
4
4
This is a pre-release for version 2.0.0.
5
5
6
-
There are no significant changes to which email addresses are considered valid/invalid, but there are many changes in error messages and internal improvements to the library including the addition of type annotations, and Python 3.7+ is now required.
6
+
There are no significant changes to which email addresses are considered valid/invalid with default options, but there are many changes in error messages and internal improvements to the library including the addition of type annotations. New options are added to allow quoted-string local parts and domain-literal addresses, but they are off by default. And Python 3.7+ is now required.
7
7
8
8
* Python 2.x and 3.x versions through 3.6, and dnspython 1.x, are no longer supported. Python 3.7+ with dnspython 2.x are now required.
9
9
* The dnspython package is no longer required if DNS checks are not used, although it will install automatically.
10
10
* NoNameservers and NXDOMAIN DNS errors are now handled differently: NoNameservers no longer fails validation, and NXDOMAIN now skips checking for an A/AAAA fallback and goes straight to failing validation.
11
11
* Some syntax error messages have changed because they are now checked explicitly rather than as a part of other checks.
12
-
* The quoted-string local part syntax (e.g. multiple @-signs, spaces, etc. if surrounded by quotes) is now parsed but not considered valid by default. Better error messages are now given for quoted-string syntax since it can be confusing for a technically valid address to be rejected, and a new allow_quoted_local option is added to allow these addresses if you really need them.
12
+
* The quoted-string local part syntax (e.g. multiple @-signs, spaces, etc. if surrounded by quotes) and domain-literal addresses (e.g. @[192.XXX...] or @[IPv6:...]) are now parsed but not considered valid by default. Better error messages are now given for these addresses since it can be confusing for a technically valid address to be rejected, and new allow_quoted_local and allow_domain_literal options are added to allow these addresses if you really need them.
13
13
* Some other error messages have changed to not repeat the email address in the error message.
14
14
* The library has been reorganized internally into smaller modules.
15
15
* The tests have been reorganized and expanded. Deliverability tests now mostly use captured DNS responses so they can be run off-line.
Copy file name to clipboardExpand all lines: README.md
+17-14Lines changed: 17 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -14,13 +14,12 @@ Key features:
14
14
15
15
* Checks that an email address has the correct syntax --- good for
16
16
registration/login forms or other uses related to identifying users.
17
-
Rejects obsolete email address syntax that you'd find unexpected.
17
+
By default, rejects obsolete email address syntax that you'd find unexpected.
18
18
* Gives friendly English error messages when validation fails that you
19
19
can display to end-users.
20
20
* Checks deliverability (optional): Does the domain name resolve?
21
21
(You can override the default DNS resolver to add query caching.)
22
-
* Supports internationalized domain names and internationalized local parts,
23
-
and with an option deprecated quoted-string local parts.
22
+
* Supports internationalized domain names and internationalized local parts.
24
23
Blocks unsafe characters for your safety.
25
24
* Normalizes email addresses (important for internationalized
26
25
and quoted-string addresses! see below).
@@ -107,7 +106,7 @@ other information.
107
106
The validator doesn't, by default, permit obsoleted forms of email addresses
108
107
that no one uses anymore even though they are still valid and deliverable, since
109
108
they will probably give you grief if you're using email for login. (See
110
-
later in the document about that.)
109
+
later in the document about how to allow some obsolete forms.)
111
110
112
111
The validator checks that the domain name in the email address has a
113
112
DNS MX record (except a NULL MX record) indicating that it can receive
@@ -137,6 +136,8 @@ The `validate_email` function also accepts the following keyword arguments
137
136
138
137
`allow_quoted_local=False`: Set to `True` to allow obscure and potentially problematic email addresses in which the part of the address before the @-sign contains spaces, @-signs, or other surprising characters when the local part is surrounded in quotes (so-called quoted-string local parts). In the object returned by `validate_email`, the normalized local part removes any unnecessary backslash-escaping and even removes the surrounding quotes if the address would be valid without them. You can also set `email_validator.ALLOW_QUOTED_LOCAL` to `True` to turn this on for all calls by default.
139
138
139
+
`allow_domain_literal=False`: Set to `True` to allow bracketed IPv4 and "IPv6:"-prefixd IPv6 addresses in the domain part of the email address. No deliverability checks are performed for these addresses. In the object returned by `validate_email`, the normalized domain will use the condensed IPv6 format, if applicable. The object's `domain_address` attribute will hold the parsed `ipaddress.IPv4Address` or `ipaddress.IPv6Address` object if applicable. You can also set `email_validator.ALLOW_DOMAIN_LITERAL` to `True` to turn this on for all calls by default.
140
+
140
141
`allow_empty_local=False`: Set to `True` to allow an empty local part (i.e.
141
142
`@example.com`), e.g. for validating Postfix aliases.
142
143
@@ -291,10 +292,12 @@ and conversion from Punycode to Unicode characters.
291
292
3.1](https://tools.ietf.org/html/rfc6532#section-3.1) and [RFC 5895
Normalization is also applied to quoted-string local parts if you have
295
-
allowed them by the `allow_quoted_local` option. Unnecessary backslash
296
-
escaping is removed and even the surrounding quotes are removed if they
297
-
are unnecessary.
295
+
Normalization is also applied to quoted-string local parts and domain
296
+
literal IPv6 addresses if you have allowed them by the `allow_quoted_local`
297
+
and `allow_domain_literal` options. In quoted-string local parts, unnecessary
298
+
backslash escaping is removed and even the surrounding quotes are removed if
299
+
they are unnecessary. For IPv6 domain literals, the IPv6 address is
300
+
normalized to condensed form.
298
301
299
302
Examples
300
303
--------
@@ -369,6 +372,7 @@ are:
369
372
|`ascii_local_part`| If set, the local part, which is composed of ASCII characters only. |
370
373
|`domain`| The canonical internationalized Unicode form of the domain part of the email address. If the returned string contains non-ASCII characters, either the [SMTPUTF8](https://tools.ietf.org/html/rfc6531) feature of your mail relay will be required to transmit the message or else the email address's domain part must be converted to IDNA ASCII first: Use `ascii_domain` field instead. |
371
374
|`ascii_domain`| The [IDNA](https://tools.ietf.org/html/rfc5891)[Punycode](https://www.rfc-editor.org/rfc/rfc3492.txt)-encoded form of the domain part of the given email address, as it would be transmitted on the wire. |
375
+
|`domain_address`| If domain literals are allowed and if the email address contains one, an `ipaddress.IPv4Address` or `ipaddress.IPv6Address` object. |
372
376
|`smtputf8`| A boolean indicating that the [SMTPUTF8](https://tools.ietf.org/html/rfc6531) feature of your mail relay will be required to transmit messages to this address because the local part of the address has non-ASCII characters (the local part cannot be IDNA-encoded). If `allow_smtputf8=False` is passed as an argument, this flag will always be false because an exception is raised if it would have been true. |
373
377
|`mx`| A list of (priority, domain) tuples of MX records specified in the DNS for the domain (see [RFC 5321 section 5](https://tools.ietf.org/html/rfc5321#section-5)). May be `None` if the deliverability check could not be completed because of a temporary issue like a timeout. |
374
378
|`mx_fallback_type`|`None` if an `MX` record is found. If no MX records are actually specified in DNS and instead are inferred, through an obsolete mechanism, from A or AAAA records, the value is the type of DNS record used instead (`A` or `AAAA`). May be `None` if the deliverability check could not be completed because of a temporary issue like a timeout. |
@@ -390,13 +394,12 @@ or likely to cause trouble:
390
394
domain names without a `.`, are rejected as a syntax error
391
395
(except see the `test_environment` parameter above).
392
396
* Obsolete email syntaxes are rejected:
393
-
The "quoted string" form of the local part of the email address (RFC
394
-
5321 4.1.2) is not permitted unless `allow_quoted_local=True` is given
395
-
(see above).
396
397
The unusual ["(comment)" syntax](https://github.com/JoshData/python-email-validator/issues/77)
397
-
is also rejected. The "literal" form for the domain part of an email address (an
398
-
IP address in brackets) is rejected. Other obsolete and deprecated syntaxes are
399
-
rejected. No one uses these forms anymore.
398
+
is rejected. Extremely old obsolete syntaxes are
399
+
rejected. Quoted-string local parts and domain-literal addresses
400
+
are rejected by default, but there are options to allow them (see above).
401
+
No one uses these forms anymore, and I can't think of any reason why anyone
0 commit comments