首页 > 编程语言 > 详细

python实现简单的发送邮件

时间:2019-06-17 13:05:09      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:服务   pex   smtp   pre   账号   login   int   ive   imp   

import smtplib
from email.mime.text import MIMEText

smtpserver = "smtp.qq.com"
port =465
sender = "发件人账号@qq.com"
psw = "smtp服务的授权码"
receiver ="收件人账号@qq.com"
body = ‘<pre><h1> </h1></pre>‘

msg = MIMEText(body,‘html‘,"utf-8")
msg[‘from‘] = sender
msg[‘to‘] = receiver
msg[‘subject‘] = "发送的内容  "
try:
smtp = smtplib.SMTP_SSL(smtpserver, port)
smtp.login(sender, psw)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
print(‘success‘)
except smtplib.SMTPException:
print(‘ERRO‘)

python实现简单的发送邮件

标签:服务   pex   smtp   pre   账号   login   int   ive   imp   

原文:https://www.cnblogs.com/wsfsd/p/11038869.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号