发邮件的模板
一個發郵件的模板
# -*- coding: utf-8 -*- ''' Created on 2014-02-17 10:41 @summary: send email @author: leaf '''import smtplib from email.mime.text import MIMEText# 收件人的郵箱地址, 一個或多個皆可,列表形式 mailto_list=['****','*****'] # 發送郵件的服務器 mail_host="smtp.**.com" # 發件人用戶名,郵箱地址中@字符之前的部分 mail_user="****" # 發件人的郵箱密碼 mail_pass="*****" #發件箱的后綴 mail_postfix="****"def send_mail(to_list,sub,content):me="hello"+"<"+mail_user+"@"+mail_postfix+">"msg = MIMEText(content,_subtype='plain',_charset='utf-8')msg['Subject'] = submsg['From'] = memsg['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 Trueexcept Exception, e:print str(e)return Falseif __name__ == '__main__':if send_mail(mailto_list,"會議通知","今天下午14:30在三樓小會議室開會"):print "發送成功"else:print "發送失敗"總結
- 上一篇: 光刻胶用于与半导体核心材料、面板、PCB
- 下一篇: 部署k8s ssl集群实践12:work