This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: UnicodeEncodeError raise from smtplib.verify() method
Type: behavior Stage:
Components: Unicode Versions: Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Windson Yang, barry, ezio.melotti
Priority: normal Keywords:

Created on 2019-02-23 07:59 by Windson Yang, last changed 2022-04-11 14:59 by admin.

Messages (4)
msg336374 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-02-23 07:59
AFAIK, the email address should support non-ASCII character (from and SMTPUTF8 
 option from

>>> import smtplib
>>> s = smtplib.SMTP(host='', port=587)
>>> s.verify('你好')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/windson/learn/cpython/Lib/", line 577, in verify
    self.putcmd("vrfy", _addr_only(address))
  File "/Users/windson/learn/cpython/Lib/", line 367, in putcmd
  File "/Users/windson/learn/cpython/Lib/", line 352, in send
    s = s.encode(self.command_encoding)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-6: ordinal not in range(128)

I found this issue when I updating
msg336375 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-02-23 08:04
Btw, from the docs

> msg may be a string containing characters in the ASCII range, or a byte string. A string is encoded to bytes using the ascii codec, and lone \r and \n characters are converted to \r\n characters. A byte string is not modified.
So we can't send non-ASCII msg using send_mail(), is this expected behavior?
msg336509 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-02-25 10:14
Barry: would you mind to have a look at this issue? It seems like smtplib encodes Unicode commands to ASCII, whereas verify() argument (SMTP "VRFY" command) is an hostname and hostname can be non-ASCII ("punycode" encoding, RFC 3492).
msg365140 - (view) Author: Windson Yang (Windson Yang) * Date: 2020-03-27 09:07
Any update?
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80274
2020-03-27 11:16:23vstinnersetnosy: - vstinner
2020-03-27 09:07:12Windson Yangsetmessages: + msg365140
2019-02-25 10:14:54vstinnersetnosy: + barry
messages: + msg336509
2019-02-23 08:04:47Windson Yangsetmessages: + msg336375
2019-02-23 07:59:18Windson Yangcreate