码迷,mamicode.com
首页 > 编程语言 > 详细

Python邮件发送功能

时间:2017-06-13 18:27:53      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:login   text   内容   cep   rom   images   pex   技术分享   授权   

import smtplib
from email.mime.text import MIMEText
_user = "1147016165@qq.com"#发件人
_pwd = "wcpxldrtuthagjbc"#qq邮箱授权码
_to = "1208832367@qq.com"#收件人

msg = MIMEText("Hellow,This is my first Email!")#邮件内容
msg["Subject"] = "come form xieolei!"#收件方显示的邮件主题
msg["From"] = _user#收件方显示的发件人
msg["To"] = _to#收件方显示的收件人

try:
  s = smtplib.SMTP_SSL("smtp.qq.com", 465)
  s.login(_user, _pwd)
  s.sendmail(_user, _to, msg.as_string())
  s.quit()

  print ("Success!")

except smtplib.SMTPException.e:

  print ("Falied,%s"%e)

技术分享

Python邮件发送功能

标签:login   text   内容   cep   rom   images   pex   技术分享   授权   

原文地址:http://www.cnblogs.com/888888CN/p/7002565.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!