zoukankan      html  css  js  c++  java
  • 关于发邮件报错535 Error:authentication failed解决方法

    相信看到535报错的同学代码编写方面都没有问题,只是不明白为什么填写了帐号密码后还是报535错误,这里我以163邮箱为例,并使用Python讲解怎么解决535问题

    1. 先编写一个最简单的发邮件的python脚本

     1 #coding: utf-8  
     2 import smtplib
     3 from email.mime.text import MIMEText
     4 from email.header import Header
     5 
     6 sender = 'huochen1994@163.com'
     7 receiver = 'huochen1994@126.com'
     8 subject = 'python email test'
     9 smtpserver = 'smtp.163.com'
    10 username = 'huochen1994@126.com'
    11 password = '*********'
    12 
    13 msg = MIMEText( 'Hello Python', 'text', 'utf-8' )
    14 msg['Subject'] = Header( subject, 'utf-8' )
    15 
    16 smtp = smtplib.SMTP()
    17 smtp.connect( smtpserver )
    18 smtp.login( username, password )
    19 smtp.sendmail( sender, receiver, msg.as_string() )
    20 smtp.quit()

    2. 运行结果

    1 Traceback (most recent call last):
    2   File "mail.py", line 18, in <module>
    3     smtp.login( username, password )  
    4   File "/usr/lib64/python2.6/smtplib.py", line 589, in login
    5     raise SMTPAuthenticationError(code, resp)
    6 smtplib.SMTPAuthenticationError: (535, 'Error: authentication failed'

    3. 解决方法

    调用163邮箱服务器来发送邮件,我们需要开启POP3/SMTP服务,这时163邮件会让我们设置客户端授权码,这个授权码替代上面代码部分的passwd即可成功发送邮件
  • 相关阅读:
    整理:深度学习 vs 机器学习 vs 模式识别
    机器学习部分国内牛人
    图像去模糊
    删除流氓软件McAfee
    ceshi
    linux系统加快大文件的写入速度
    修改cmd的字体为Consolas字体
    gdb的可视化工具安装
    微服务编译、启动jar命令指定配置文件
    pycharm中安装可以贴图片的Markdown插件
  • 原文地址:https://www.cnblogs.com/fengyiru6369/p/7472524.html
Copyright © 2011-2022 走看看