相关疑难解决方法(0)

Python 3 smtplib使用unicode字符发送

我在使用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消息示例发送

有什么建议?

python email unicode smtplib python-3.x

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

email ×1

python ×1

python-3.x ×1

smtplib ×1

unicode ×1