我使用Python模块MimeWriter构造消息,smtplib发送邮件构造的消息是:
file msg.txt:
-----------------------
Content-Type: multipart/mixed;
from: me<me@abc.com>
to: me@abc.com
subject: ??
Content-Type: text/plain;charset=utf-8
??
Run Code Online (Sandbox Code Playgroud)
我使用下面的代码发送邮件:
import smtplib
s=smtplib.SMTP('smtp.abc.com')
toList = ['me@abc.com']
f=open('msg.txt') #above msg in msg.txt file
msg=f.read()
f.close()
s.sendmail('me@abc.com',toList,msg)
Run Code Online (Sandbox Code Playgroud)
我正确收到邮件正文,但主题不合适,
subject: some junk characters
?? <- body is correct.
Run Code Online (Sandbox Code Playgroud)
请指教?有没有办法指定用于主题的解码,如为正文指定的那样.如何正确解码主题?