python3 发邮件,从文件读邮件内容和发送html内容
2011-08-03 17:03
721 查看
#!/usr/bin/python #coding=gbk import smtplib from email.mime.text import MIMEText from urllib.request import urlopen #从文件读 file_ob=open('/home/mailcontent.txt') try: content=file_ob.read() finally: file_ob.close() msg=MIMEText(content,'plain','utf-8') msg['Subject']='this is a test from python' msg['From']='from@163.com' msg['To']='to@qq.com' #从网页读 f=urlopen('http://www.pcesen.com') msg=MIMEText(f.read(),'html','utf-8') msg['Subject']='this is a test from python' msg['From']='from@163.com' msg['To']='to@qq.com' smtp=smtplib.SMTP() smtp.connect("smtp.163.com","25") smtp.login('from','password') smtp.sendmail('from@163.com','to@qq.com',msg.as_string()) smtp.quit()
相关文章推荐
- python爬虫实现带附件+html内容以及图片的邮件发送
- 【Python系列】Python自动发邮件脚本-html邮件内容
- python读取\t\n的文件转换成html表格发送邮件(解决中文乱码问题)
- python应用系列教程——python使用smtp协议发送邮件:html文本邮件、图片邮件、文件附件邮件
- python 七种邮件内容发送方法实例
- 根据资源文件的内容判断按时或按天或按月发送邮件
- python 发送html邮件
- python发送包含html、图片、附件和链接的邮件
- python 七种邮件内容发送方法实例
- python自动发送邮件自定义邮件发件人和收件人的显示内容
- 将PPT文件内容转换为图片放在Email邮件正文中发送
- python 七种邮件内容发送方法实例
- 关于javaMail的发送邮件之简便方法(邮件带有附件及html内容中携带图标)
- python3 发送邮件(二)(html)(qq)
- PHPMailer发送HTML内容、带附件的邮件实例
- python发送包含html、图片、附件和链接的邮件
- 实现发送邮件动态html内容的几种思路
- INDY发送html邮件带附件邮件内容不能正确显示的问题
- python 2.7 利用smtplib发送、抄送邮件以及发送html表格
- Python提取MySQL数据为EXCEL文件后邮件发送