#coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = '×××@163.com'
receiver = '×××@qq.com'
subject = 'python email test2'
smtpserver = 'smtp.163.com'
username = '×××'
password = '×××' # 授权码,不是密码
msg = MIMEText('你好','text','utf-8')#中文需参数‘utf-8’,单字节字符不需要
msg['Subject'] = Header(subject, 'utf-8')
msg["To"]=receiver
smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
------------如果passwd不是授权码的话,报错如下-------------------
jack@jack-desktop:~/work/script/test$ python testemai.py
Traceback (most recent call last):
File "testemai.py", line 19, in <module>
smtp.login(username, password)
File "/home/jack/anaconda/lib/python2.7/smtplib.py", line 622, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, 'Error: authentication failed')
jack@jack-desktop:~/work/script/test$ python testemai.py
Traceback (most recent call last):
File "testemai.py", line 19, in <module>
smtp.login(username, password)
File "/home/jack/anaconda/lib/python2.7/smtplib.py", line 622, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, 'Error: authentication failed')
分享到:
相关推荐
python发送邮件代码,服务器配置请自行修改,脚本中的地址是内网搭建的邮件服务器。可以结合系统定时任务配置邮件定时发送。希望帮到你
Python发邮件代码
python发送邮件报表
半天时间写了个python发送邮件的脚本 作者: jeffery ( email:dungeonsnd@126.com, msn:dungeonsnd@hotmail.com, csdn blog:http://blog.csdn.net/dungeonsnd) 时间: 2011-06-19 地点: SH --------------------------...
简单的python发送邮件的示例,基于python2.7
python发送邮件源码有注释
这是python发送邮件的源码,支持群发和添加邮件, 文章中有免费下载地址,这里是土豪专用下载地址,
python发送邮件的脚本 作者: jeffery ( email:dungeonsnd@126.com, msn:dungeonsnd@hotmail.com, csdn blog:http://blog.csdn.net/dungeonsnd) 时间: 2011-07-10 地点: GZ ----------------------------------------...
基于Python实现多进程的发送邮件.zip
使用python3发送QQ电子邮件,发送人为自己,接收人可以一个可以多个。
使用smtplib前,请使用telnet smtp.126.com 25确保端口能访问到
python发送邮件---包含重发(三次)和定时统计
该文档介绍了两种利用python发送邮件的方式,包括响应模块导入,邮件正文等。
1)程序功能:PHP调用Python发送邮件。 2)程序详解地址:http://blog.csdn.net/clevercode/article/details/45815453。 3)原创作品,出自"CleverCode的博客",本程序不得用于商业用途,仅做学习交流。 4)欢迎大家...
当抓取的信息更新的时候,可以通过邮件进行动态通知
python发送邮件功能,不使用stmplib 使用一个包装好的库,更方便。
python发送带附件的邮件代码,大家可以看看哟。亲测无问题。
python GUI实现简易发送邮件程序。
python 发送邮件、添加附件、读取邮箱邮件完整脚本。有问题,请添加博主,留言