@@ -77,11 +77,11 @@ from email_validator import validate_email, caching_resolver
77
77
resolver = caching_resolver(timeout = 10 )
78
78
79
79
while True :
80
- valid = validate_email(email, dns_resolver = resolver)
80
+ email = validate_email(email, dns_resolver = resolver).email
81
81
```
82
82
83
83
The validator will accept internationalized email addresses, but not all
84
- mail systems can send email to an addresses with non-ASCII characters in
84
+ mail systems can send email to an addresses with non-English characters in
85
85
the * local* part of the address (before the @-sign). See the ` allow_smtputf8 `
86
86
option below.
87
87
@@ -90,12 +90,13 @@ Overview
90
90
--------
91
91
92
92
The module provides a function ` validate_email(email_address) ` which
93
- takes an email address (either a ` str ` or ASCII ` bytes ` ) and:
93
+ takes an email address (either a ` str ` or ` bytes ` , but only non-internationalized
94
+ addresses are allowed when passing a ` bytes ` ) and:
94
95
95
96
- Raises a ` EmailNotValidError ` with a helpful, human-readable error
96
97
message explaining why the email address is not valid, or
97
- - Returns an object with a normalized form of the email address and
98
- other information about it.
98
+ - Returns an object with a normalized form of the email address (which
99
+ you should use!) and other information about it.
99
100
100
101
When an email address is not valid, ` validate_email ` raises either an
101
102
` EmailSyntaxError ` if the form of the address is invalid or an
@@ -141,7 +142,7 @@ Internationalized email addresses
141
142
---------------------------------
142
143
143
144
The email protocol SMTP and the domain name system DNS have historically
144
- only allowed ASCII characters in email addresses and domain names,
145
+ only allowed English ( ASCII) characters in email addresses and domain names,
145
146
respectively. Each has adapted to internationalization in a separate
146
147
way, creating two separate aspects to email address
147
148
internationalization.
@@ -167,11 +168,17 @@ using the [idna](https://github.com/kjd/idna) module by Kim Davies.
167
168
### Internationalized local parts
168
169
169
170
The second sort of internationalization is internationalization in the
170
- * local* part of the address (before the @-sign). These email addresses
171
- require that your mail submission library and the mail servers along the
172
- route to the destination, including your own outbound mail server, all
173
- support the [ SMTPUTF8 (RFC 6531)] ( https://tools.ietf.org/html/rfc6531 )
174
- extension. Support for SMTPUTF8 varies.
171
+ * local* part of the address (before the @-sign). In non-internationalized
172
+ email addresses, only English letters, numbers, and some punctuation
173
+ (` ._!#$%&'^``*+-=~/?{|} ` ) are allowed. In internationalized email address
174
+ local parts, all Unicode characters are allowed by this library, although
175
+ it's possible that not all characters will be allowed by all mail systems.
176
+
177
+ To deliver email to addresses with Unicode, non-English characters, your mail
178
+ submission library and the mail servers along the route to the destination,
179
+ including your own outbound mail server, must all support the
180
+ [ SMTPUTF8 (RFC 6531)] ( https://tools.ietf.org/html/rfc6531 ) extension.
181
+ Support for SMTPUTF8 varies. See the ` allow_smtputf8 ` parameter.
175
182
176
183
### If you know ahead of time that SMTPUTF8 is not supported by your mail submission stack
177
184
0 commit comments