Python SMTPLIB
来源:互联网 发布:藏文输入法软件下载 编辑:程序博客网 时间:2024/06/14 21:41
Python简单邮件代码
#! /user/bin/python
#-*-coding: UTF-8-*-
import smtplib, mimetypes
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
msg = MIMEMultipart()
msg["From"] = "xxxxxx"
msg["To"] = "xxxxxx"
msg["Subject"] = "Test SMTP by Python"
text = MIMEText("This is text content")
msg.attach(text)
filename = r'F:\ttt.txt'
ctype,encoding = mimetypes.guess_type(filename)
if ctype is None or encoding is not None:
ctype = "application/octet-stream"
maintype,subtype = ctype.split('/',1)
att = MIMEImage(open(filename,'r').read(),subtype)
print ctype,encoding
att["Content-Disposition"] = "attachment;filename='ttt.txt'"
msg.attach(att)
smtp = smtplib.SMTP()
smtp.connect("smtp.163.com")
smtp.login("xxxx","xxxx")
smtp.sendmail(msg["From"],msg["To"],msg.as_string())
smtp.quit()
print "send mail successfully"
- Python SMTPLIB
- Python-smtplib
- python的smtplib
- python学习--smtplib
- #python# smtplib 邮件发送
- Python 邮件发送smtplib
- Python模块学习--smtplib
- python smtplib 发送邮件
- python 利用smtplib发送邮件
- PYTHON模块学习之smtplib
- Python之smtplib邮件模块
- Python使用smtplib发送邮件
- python解析Json、smtplib初解
- python的smtplib发邮件
- python发邮件smtplib+mail
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- Android 实现个性的ViewPager切换动画 实战PageTransformer(兼容Android3.0以下)
- UVA11796 Dog Distance 计算几何
- yacc lex 词法解析与语法解析
- Struck: Structrued Output Tracking with Kernels 论文笔记
- ASP.NET的分布式缓存介绍,MyCache ,Memcached ,CacheManager
- Python SMTPLIB
- Real-Time Compressive Tracking 论文笔记
- windows多执行绪代码及分析
- 架构师:一群善于沟通的技术领袖
- LCD帧缓存设备驱动
- hdu 1333 Smith Numbers
- LCD驱动的实现
- bash shell脚本之查看当前日期以及登陆用户
- 架构师:要成为百科全书式的智者