用qq的smtp发送邮件包编码错误,请问怎么解决,已设置了utf-8
import smtplib
from email.mime.text import MIMEText
smtpserver="smtp.qq.com"
port = 465
sender="2453*******95@qq.com"
psw="refezmt**********djgd"
receiver="2453******95@qq.com"
subject='你好'
body='<h1>错误</h1>'
msg=MIMEText(body,"html","utf-8")
msg["from"]=sender
msg["to"]=receiver
msg["subject"]=subject
smtp=smtplib.SMTP()
smtp.connect(smtpserver)
smtp=smtplib.SMTP_SSL(smtpserver,port)
smtp.login(sender,psw)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()
报错如下
Traceback (most recent call last):
File "E:/python_project/bixia/send.py", line 18, in <module>
smtp=smtplib.SMTP()
File "H:\python\lib\smtplib.py", line 261, in __init__
fqdn = socket.getfqdn()
File "H:\python\lib\socket.py", line 676, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 0: invalid start byte