首页 > 代码库 > python不同的内容邮件群发

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