关于发邮件报错535 Error:authentication failed解决方法
2016-04-29 15:19
423 查看
关于发邮件报错535 Error:authentication failed解决方法
写在最前面
相信看到535报错的同学代码编写方面都没有问题,只是不明白为什么填写了帐号密码后还是报535错误,这里我以163邮箱为例,并使用Python讲解怎么解决535问题1. 先编写一个最简单的发邮件的python脚本
#coding: utf-8 import smtplib from email.mime.text import MIMEText from email.header import Header sender = 'huochen1994@163.com' receiver = 'huochen1994@126.com' subject = 'python email test' smtpserver = 'smtp.163.com' username = 'huochen1994@126.com' password = '*********' msg = MIMEText( 'Hello Python', 'text', 'utf-8' ) msg['Subject'] = Header( subject, 'utf-8' ) smtp = smtplib.SMTP() smtp.connect( smtpserver ) smtp.login( username, password ) smtp.sendmail( sender, receiver, msg.as_string() ) smtp.quit()
2. 运行结果
如果在上述代码username和
password,变量中填写邮箱的帐号密码那么会看到以下报错:
Traceback (most recent call last): File "mail.py", line 18, in <module> smtp.login( username, password ) File "/usr/lib64/python2.6/smtplib.py", line 589, in login raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, 'Error: authentication failed')
3. 解决方法
调用163邮箱服务器来发送邮件,我们需要开启POP3/SMTP服务,这时163邮件会让我们设置客户端授权码,这个授权码替代上面代码部分的passwd即可成功发送邮件
相关文章推荐
- You raise me up
- Neutron/L3 High Availability VRRP
- 【HDU】 1532 Drainage Ditches
- count(字段)不统计null值http://blog.csdn.net/lwei_998/article/details/6112810
- FZCCHJW--GB1-0-GBpc-EUC-H:在系统中未找到字体;已替换缺少的字体。
- leetcode 11. Container With Most Water
- stitching detail输出的dot图含义
- 从零开始写聊天机器人
- AI教程!教你绘制扁平化风格的卡通人物肖像(四人组合篇)
- UVa 10976 Fractions Again?!
- RAID详解[RAID0/RAID1/RAID10/RAID5]
- Exception raised during rendering: Binary XML file line #-1: No start tag found!
- svmtrain和svmpredict参数
- 当人工智能遇见金融财经
- 线程中sleep和wait的区别
- memcache的使用http://blog.csdn.net/scelong/article/details/7245343
- 217. Contains Duplicate
- Metastore contains multiple versions
- http://blog.csdn.net/hahalzb/article/details/5889545
- 人工智能正在向经济学领域渗透