#!/usr/bin/python
# coding: UTF-8
import smtplib
from email.mime.text import MIMEText
receivers_list=["chengang@example.com",]
#mail_host="dns.com"
mail_host="1.2.3.4"
sender_email="send@bat.com"
#mail_pwd="*************" //有的需要,有的不需要
def send_email(subject, content, receivers_list):
print 'Setting MIMEText'
msg = MIMEText(content.encode('utf8'), _subtype = 'html', _charset = 'utf8')
msg['From'] = sender_email
msg['Subject'] = u'%s' % subject
msg['To'] = ",".join(receivers_list)
try:
# s = smtplib.SMTP_SSL(mail_host, 465) //有的需要,有的不需要
s = smtplib.SMTP(mail_host, 25)
# s.connect(mail_host) //和上面的连接任选一种