首页 > 编程语言 > 详细

python#模拟发送电子邮件

时间:2016-06-03 10:03:57      阅读:257      评论:0      收藏:0      [点我收藏+]
 1 #-*- coding:utf-8 -*-
 2 #模拟发送电子邮件
 3 from email.mime.text import MIMEText
 4 
 5 
 6 from_addr = aa@sss.com
 7 password = input(Passord:)
 8 to_addr = test8@qq.com
 9 
10 smtp_server = mail.lingrui.com
11 
12 context =  为此次峰会互动提供了礼品支持,冬
13 
14 msg = MIMEText(context,plain,utf-8)
15 msg[Subject]=Python send mail
16 msg[From] = from_addr
17 
18 import smtplib
19 
20 server = smtplib.SMTP(smtp_server,25)
21 server.set_debuglevel(1)
22 server.login(from_addr,password)
23 server.sendmail(from_addr,[to_addr],msg.as_string())
24 server.quit()
25 
26 print(邮件发送至 %s 成功 %to_addr)

 

python#模拟发送电子邮件

原文:http://www.cnblogs.com/lrzy/p/5555071.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!