python 邮件发送模板
来源:互联网 发布:mysql多个约束 编辑:程序博客网 时间:2024/05/18 01:27
文本内容:
#!/usr/bin/env python# -*- coding=utf-8 -*-import smtplibfrom email.mime.text import MIMETextdef send_mail(to_list,sub,content): mail_host = "***" # 设置服务器 mail_user = "***" # 用户名 mail_pass = "***" # 口令 mail_postfix = "***" # 发件箱的后缀 mail_port = *** # 端口 sender="Alerter"+"<"+mail_user+"@"+mail_postfix+">" msg = MIMEText(content,_subtype='plain',_charset='utf-8') msg['Subject'] = sub msg['From'] = sender msg['To'] = ";".join(to_list) try: server = smtplib.SMTP() server.connect(mail_host, mail_port) server.login(mail_user, mail_pass) server.sendmail(sender, to_list, msg.as_string()) server.close() return True except Exception, e: print str(e) return Falseif __name__ == '__main__': subject='text_test' send_content = '' mailto_list=['***@163.com',...] send_mail(mailto_list, subject, send_content)
html 内容:
def send_mail(to_list,sub,content): mail_host = "***" # 设置服务器 mail_user = "***" # 用户名 mail_pass = "***" # 口令 mail_postfix = "***" # 发件箱的后缀 mail_port = *** # 端口 sender="Alerter"+"<"+mail_user+"@"+mail_postfix+">" msg = MIMEText(content,_subtype='html',_charset='utf-8') msg['Subject'] = sub msg['From'] = sender msg['To'] = ";".join(to_list) try: server = smtplib.SMTP() server.connect(mail_host, mail_port) server.login(mail_user, mail_pass) server.sendmail(sender, to_list, msg.as_string()) server.close() return True except Exception, e: print str(e) return False
阅读全文
0 0
- python发送邮件模板
- python 邮件发送模板
- python 发送邮件的模板
- spring 邮件 发送模板
- 用Python发送邮件
- Python 发送邮件
- python 邮件发送
- 使用PYTHON发送邮件
- python邮件发送
- python发送邮件程序
- python: 发送邮件
- python发送邮件
- python smtp发送邮件
- python 发送邮件实例
- python发送各类邮件
- 用Python发送邮件
- 用Python发送邮件
- python 发送邮件实例
- Linux(CentOS)下同时启动两个tomcat
- golang语言并发与并行—goroutine和channel的详细理解
- Java:实现商品的查找、添加、出库、入库
- Bond behaviour with reinforcement corrosion
- python_画九点分布图
- python 邮件发送模板
- Office 365 online的基本概念
- scp & cat远程文件操作
- JAVA集合
- android问题大全
- centos6.5上离线安装gcc
- 计算机网络之面试常考
- uwsgi+django+nginx配置问题总结
- 跨浏览器的事件侦听器和事件对象