python模块-email,smtplib
本帖最后由 ning_lianjie 于 2015-02-26 14:22 编辑顾名思义,就是发邮件用的,闲话不说了,直接上代码
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
def send_mail():
body = '''邮件内容'''
addr_to = 'a1@export.com,a2@export@qunar.com' # 要给多人发送或者抄送时,将要接收的人拼成list,至于msg['to'] msg['cc'] msg['bcc']这些只是做显示而已
msg = MIMEText(body, 'html', 'utf8')
msg['to'] = 'a1@export.com'
msg['cc'] = 'a2@export.com'
msg['from'] = 'localhost@export.com'
msg['subject'] = u'提醒 - 慢查询已经被KILL - 数据库地址' # 主题前面加个u, 避免个别客户端乱码
s_msg = smtplib.SMTP('localhost') # 本机开了smtp服务
s_msg.sendmail('', addr_to.split(','), msg.as_string('Ture'))
s_msg.quit()
if __name__ == '__main__':
send_mail()
哦 MT然后? 可以插入吗?? 非常高兴遇到这么好的帖子 谢谢 回复 3# sydt
不明白...
回复 4# ss8875
:handshake
页:
[1]