python不同的内容邮件群发
#!/usr/bin/env python
#coding:utf8
import smtplib,sys
from email.mime.text import MIMEText
from config.mailss import mail_list,content
def send_mail():
mail_host,mail_user,mail_pass,mail_postfix,sub,me,mailto_list = mail_list
me=mail_user+"<"+mail_user+"@"+mail_postfix+">"
for i in xrange(len(content)):
msg = MIMEText(content[i],_charset=‘gbk‘)
msg[‘Subject‘] = sub
msg[‘From‘] = me
for i in mailto_list:
msg[‘To‘] = "".join(i)
# try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me, mailto_list, msg.as_string())
s.close()
本文出自 “原创python发布区” 博客,请务必保留此出处http://cuihailong.blog.51cto.com/2923450/1409562
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。