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

python#模拟发送电子邮件

时间:2016-06-03 10:06:31      阅读:247      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!