我正在学习运行以下代码的教程。
import smtplib
email_user = 'email@gmail.com'
email_send = 'email@gmail.com'
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login(email_user,'pass')
message = 'Hello'
server.sendmail(email_user,email_send,message)
server.quit()
不幸的是,代码抛出错误:
Traceback (most recent call last):
File "C:\Users\lol\PycharmProjects\untitled\venv\lib\encodings\idna.py", line 165, in encode
raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:/Users/lol/PycharmProjects/untitled/hello.py", line 27, in <module>
server = smtplib.SMTP('smtp.gmail.com', 587)
File "C:\Users\lol\AppData\Local\Programs\Python\Python36-32\Lib\smtplib.py", line 261, in __init__
fqdn = socket.getfqdn()
File "C:\Users\lol\AppData\Local\Programs\Python\Python36-32\Lib\socket.py", line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)
我该如何解决这个问题?