python xml sendEmail
2015-08-07 16:40
525 查看
使用python进行发送邮件,研究的主要是用smtplib这个包,具体代码如下,eg:
这里需要说的是为什么使用163的邮箱,因为我刚开始在这里登录邮箱是使用qq邮箱,结果使用qq邮箱很久都没有成功,报各种错误,然后找了一下可能是smtp的原因,换成163邮箱果断成功了。
#!/usr/bin/python #coding=utf-8 import smtplib from email.mime.text import MIMEText def sm(receiver, title, body): host = 'smtp.163.com' port = 25 sender = '*****@163.com' pwd = '********' msg = MIMEText(body, 'html') msg['subject'] = title msg['from'] = sender msg['to'] = receiver s = smtplib.SMTP(host, port) s.login(sender, pwd) s.sendmail(sender, receiver, msg.as_string()) print 'The mail named %s to %s is sended successly.' % (title, receiver) sm('****@qq.com','Hello,World','This is test send email')
这里需要说的是为什么使用163的邮箱,因为我刚开始在这里登录邮箱是使用qq邮箱,结果使用qq邮箱很久都没有成功,报各种错误,然后找了一下可能是smtp的原因,换成163邮箱果断成功了。
相关文章推荐
- python 杀进程 判断文件是否存在 查看进程
- python引用和复制一个对象
- python udp 广播
- Python3 Counter类计算list中元素出现次数
- Python3 列表List或元组tuple中元素分解(赋值操作)
- Python 的列表排序
- 【Python】[函数] 函数的参数与递归函数
- python udpserver decorator 修饰类
- Python学习笔记06
- python之__name__属性
- python trackback的使用心得
- Python学习笔记
- 20150805-20150807 tradeDate-----python
- python none,null,,,,,类型
- python none,null,,,,,类型
- Python 传参
- Python长字符串的打印
- python - Local variable referenced before assignment
- Python安装
- Mac 下python安装virtualen与配置