a979172331
2021-04-19 11:31
采纳率: 100%
浏览 140
已采纳

python发送QQ邮件,QQ邮件列表不显示发件人

在QQ列表里不显示发件人。点开邮件后,里面有发件人。这是为什么? 

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header

mail_host="smtp.qq.com"
mail_sender="xxxxxx@qq.com"
mail_pass="xxxxxxxx"
mail_receivers=["xxxxxx@qq.com"]

message=MIMEMultipart('related')
message["From"]="崽,阿爸对你很失望<xxxxxx@qq.com>"
message["To"]="仔仔<xxxxxx@qq.com>"
subject="啊啊啊啊啊啊"
message["subject"]=Header(subject,'utf-8')

body_content="""哈哈哈哈,嗷嗷嗷!"""
message_text=MIMEText(body_content,"plain","utf-8")
message.attach(message_text)

try:
    smtpobj=smtplib.SMTP()
    smtpobj.connect(mail_host,25)
    smtpobj.login(mail_sender,mail_pass)
    smtpobj.sendmail(mail_sender,mail_receivers,message.as_string())
    print("成功")
except smtplib.SMTPException:
    print("失败")
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • Nick Peng 2021-04-19 17:01
    已采纳

    message["From"]="崽,阿爸对你很失望<xxxxxx@qq.com>"    换成这样的试试    message['From'] ="xxxxxx@qq.com"

    评论
    解决 1 无用
    打赏 举报
  • 查看更多回答(2条)

相关推荐 更多相似问题