利用网易邮箱发送邮件535报错处理

2020-09-03 15:22:20 浏览数 (2)

相信看到535报错的同学代码编写方面都没有问题,只是不明白为什么填写了帐号密码后还是报535错误,使用网易的126或者163邮箱都会有如此问题。

Python报错如下:

代码语言:javascript复制
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')

Java报错如下:

代码语言:javascript复制
17:42:41.035 ERROR [ChannelSystem-akka.actor.default-dispatcher-8] EmailUtil - Send mail failed.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.163.com:25
       at com.cloudwise.bdp.alert.channel.sender.email.CustomHtmlEmail.sendMimeMessage(CustomHtmlEmail.java:48) ~[alert-channel-2.0.0.jar:na]
       at org.apache.commons.mail.Email.send(Email.java:1448) ~[commons-email-1.4.jar:1.4]
       at com.cloudwise.bdp.alert.channel.sender.email.EmailUtil.send(EmailUtil.java:91) [alert-channel-2.0.0.jar:na]
       at com.cloudwise.bdp.alert.channel.sender.email.EmailUtil.send(EmailUtil.java:135) [alert-channel-2.0.0.jar:na]
       at com.cloudwise.bdp.alert.channel.actor.ChannelFuture.call(ChannelFuture.java:113) [alert-channel-2.0.0.jar:na]
       at com.cloudwise.bdp.alert.channel.actor.ChannelFuture.call(ChannelFuture.java:20) [alert-channel-2.0.0.jar:na]
       at akka.dispatch.Futures$$anonfun$future$1.apply(Future.scala:95) [akka-actor_2.10-2.3.16.jar:na]
       at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [scala-library-2.10.4.jar:na]
       at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [scala-library-2.10.4.jar:na]
       at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) [akka-actor_2.10-2.3.16.jar:na]
       at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) [akka-actor_2.10-2.3.16.jar:na]
       at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.10.4.jar:na]
       at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.10.4.jar:na]
       at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.10.4.jar:na]
       at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.10.4.jar:na]
Caused by: javax.mail.AuthenticationFailedException: 535 Error: authentication failed

如果你利用网易邮箱发送邮件password字段配置成登录用户密码的时候,经常会遇到如上错误。

解决方法如下: 调用网易邮箱服务器来发送邮件,我们需要开启POP3/SMTP服务,这时网易邮件会让我们设置客户端授权码,这个授权码替代我们设置发送邮件用户的password即可成功发送邮件, 设置流程如下:

按照如上如1 2 3 4 5 6的顺序设置客户端授权码,设置完成后把你配置的password的值替换成你设置的客户端授权码,例如我上面设置的是test123, 如果你想重置授权码的话,如下图所示:

0 人点赞