发送邮件时候遇到了这样的一个错误!Sending the email to the following server failed : smtp.163.com:25

时间:2021-01-09 18:12:10
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.163.com:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1189)
at org.apache.commons.mail.Email.send(Email.java:1214)
at com.zsb.util.SendEmailUtil.getSendEmail(SendEmailUtil.java:31)
at com.zsb.action.ActivateMailAction.registerPwd(ActivateMailAction.java:76)
at com.zsb.action.ActivateMailAction.doPost(ActivateMailAction.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.mail.MessagingException: Exception reading response;
  nested exception is:
java.net.SocketTimeoutException: Read timed out
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2210)
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:2078)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2111)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1900)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1122)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1179)
... 26 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2188)

... 33 more



其实这个错误很简单,因为有三种可能,

1.是端口写错了,但是我的端口 没有写错sendemail.setHostName("smtp.163.com");

2是没有开通验证,但是我上个星期已经开通过了,而且用 的时候也很顺利。这个也没有问题

3.就是密码错了,果然。我登录163邮箱查看的时候,那个发送邮箱的授权密码已经过期了!改过来就没事了发送邮件时候遇到了这样的一个错误!Sending the email to the following server failed : smtp.163.com:25