QQ邮箱接收MIMEText的内容为空

来源:互联网 发布:深圳海思 知乎 编辑:程序博客网 时间:2024/05/17 07:47
#!/usr/bin/python
#-*- coding: utf-8 -*-
from smtplib import SMTP_SSL
from email.header import Header
from email.mime.text import MIMEText


From = "*****@xxx.com"
To = "*****1@xxx.com"
smtp = SMTP_SSL("smtp.qq.com")
smtp.set_debuglevel(1)
smtp.ehlo("smtp.qq.com")
#发送邮件的邮箱账号和授权码
smtp.login(From,"******")
#前面可以发送内容、后面无法发送内容
msg = MIMEText("你好","text","utf-8")
msg["Subject"] = Header("this is title","utf-8")
msg["Sender"] = From
msg["Reciver"] = To
smtp.sendmail(From, To, msg.as_string())

smtp.quit()


这样子只接收到标题没有内容

msg = MIMEText("你好","text","utf-8")

改成msg = MIMEText("你好")

就可以在qq邮箱接收到“你好”的内容


目前对MIMEText还不是很了解。

有错误留言,谢谢~

0 0