这是代码:
import smtplib
sender = "" #sender email here
receiver = "" #reciver email here
password = input(str("Password: "))
message = "This email sent using python."
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(sender, password)
print("Login sucsess.")
server.sendmail(sender, receiver, message)
print("Email sent.")
但是我得到了这个错误:
Traceback (most recent call last):
File "C:\Users\36704\Desktop\email_practice.py", line 12, in <module>
server.sendmail(sender, receiver, message)
File "C:\Python\Python38\lib\smtplib.py", line 859, in sendmail
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character '\xf3' in position 13: ordinal not in range(128)
它根本不起作用。我该怎么办?