标签:smt smtp login 发送 测试 import list 服务 pass
#/usr/bin/enn python #coding=utf-8 import smtplib from email.mime.text import MIMEText msg_from = 'w673004708@163.com' passwd = 'H天天' msg_to = "liuhaixia@23432" mail_host="smtp.163.com" port= 465 subject = "python邮件测试" content = "Hello World" msg = MIMEText(content) msg['Subject'] = subject msg['From'] = msg_from #创建连接对象并连接到服务器 s = smtplib.SMTP_SSL(mail_host,port) # 登录服务器 mail_list = ["w67308@163.com","liuha@see.com.cn"] s.login(msg_from, passwd) i=0 for i in range(0, len(mail_list)): msg_to = mail_list[i] msg['To'] = msg_to s.sendmail(msg_from, msg_to, msg.as_string()) print "发送成功" i=i+1标签:smt smtp login 发送 测试 import list 服务 pass
原文地址:http://blog.51cto.com/wsxxsl/2069030