我在使用Python 3中的smtplib通过电子邮件发送unicode字符时遇到问题.这在3.1.1中失败,但在2.5.4中有效:
import smtplib
from email.mime.text import MIMEText
sender = to = 'ABC@DEF.com'
server = 'smtp.DEF.com'
msg = MIMEText('€10')
msg['Subject'] = 'Hello'
msg['From'] = sender
msg['To'] = to
s = smtplib.SMTP(server)
s.sendmail(sender, [to], msg.as_string())
s.quit()
Run Code Online (Sandbox Code Playgroud)
我尝试了一些来自文档的例子,但也失败了. http://docs.python.org/3.1/library/email-examples.html,将目录内容作为MIME消息示例发送
有什么建议?