发布时间:2019-07-24 09:48:33编辑:auto阅读(1537)
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
import sys
import os
import datetime
import time
import MySQLdb
import subprocess
reload(sys)
sys.setdefaultencoding("utf-8")
mailto_list = ["xxx@163.com"] #目标邮箱
mail_host = "smtp.163.com"
mail_user = "xxx@163.com"
mail_pass = "lecpuedugk" #163邮箱smtp生成的密码
def send_mail(to_list, sub, content):
me = "LogServer"+"<"+mail_user+">"
msg = MIMEText(content, _subtype='plain', _charset='utf-8')
msg['Subject'] = sub
msg['From'] = me
msg['To'] = ";".join(to_list)
try:
server = smtplib.SMTP()
server.connect(mail_host)
server.login(mail_user, mail_pass)
server.sendmail(me, to_list, msg.as_string())
server.close()
return True
except Exception, e:
print str(e)
return False
if __name__ == '__main__':
send_mail(mailto_list, 'submit', 'content')
上一篇: python3 引号中嵌套引号
下一篇: hadoop2.7第一个python实例
47485
45787
36785
34318
28956
25590
24437
19607
19103
17628
5459°
6042°
5565°
5633°
6567°
5371°
5371°
5879°
5852°
7164°