python 发送邮件
来源:互联网 发布:海口seo 编辑:程序博客网 时间:2024/04/30 23:01
@staticmethod
def send_mail(subject, content, mail_list,filename =None):
MAIL_FROM = APP_CFG.MAIL_USER_NAME + "<"+APP_CFG.MAIL_USER+">"
message = MIMEMultipart()
message.attach(MIMEText(content,'plain','utf-8'))
message["Subject"] = Header(subject, 'utf-8')
message["From"] = Header(MAIL_FROM, 'utf-8')
message["To"] = ";".join(mail_list)
if filename != None and os.path.exists(filename):
basename = os.path.basename(filename)
att = MIMEText(open(filename, 'rb').read(),'base64', 'gb2312')
att["Content-Type"] ='application/octet-stream'
att["Content-Disposition"] ='attachment; filename=%s' % basename.encode('gb2312')
message.attach(att)
smtp = smtplib.SMTP()
smtp.connect(APP_CFG.MAIL_HOST)
smtp.login(APP_CFG.MAIL_USER, APP_CFG.MAIL_PASS)
smtp.sendmail(MAIL_FROM, mail_list, message.as_string())
smtp.quit()
- 用Python发送邮件
- Python 发送邮件
- python 邮件发送
- 使用PYTHON发送邮件
- python邮件发送
- python发送邮件程序
- python: 发送邮件
- python发送邮件
- python smtp发送邮件
- python 发送邮件实例
- python发送各类邮件
- 用Python发送邮件
- 用Python发送邮件
- python 发送邮件实例
- Python发送邮件测试
- python发送邮件
- python发送邮件
- python发送邮件
- 视音频一些程序小demo
- C++中强制转换
- 一位老工程师前辈的忠告
- HEU Tunnels(常规最小生成树)
- 北京联合大学csdn高校俱乐部第四期活动
- python 发送邮件
- php 调用 linux 的一点问题
- Jquery之弹出层插件FancyBox
- HEU Mining Station on the Sea(最小费用最大流)
- android之两个不同程序的彼此调用
- Hibernate 的 SessionFactory接口
- .NET 实现解析全国各大视频网站真实视频下载地址
- 脉冲边沿检测(Verilog)
- JQuery 学习总结及实例