当前位置: 代码迷 >> 综合 >> 解决错误503:com.sun.mail.smtp.SMTPAddressFailedException: 503 the server need auth(15D98013BE0)
  详细解决方案

解决错误503:com.sun.mail.smtp.SMTPAddressFailedException: 503 the server need auth(15D98013BE0)

热度:96   发布时间:2023-12-21 11:41:36.0

最近遇见了一奇葩的问题:排查14年其他人开发的系统(已经接近退休的项目,突然领导要看)无法发送邮件的过程中发现在linux下无法发送邮件,并且报如下错误:

javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:com.sun.mail.smtp.SMTPAddressFailedException: 503 the server need auth(15D98013BE0)


at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at com.platomix.yixintong.util.SimpleMailSender.sendMail(SimpleMailSender.java:72)
at com.platomix.yixintong.service.impl.ProxyServiceImpl.sendMail(ProxyServiceImpl.java:845)
at com.platomix.yixintong.action.ProxyAction.mirrorinterface(ProxyAction.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:504)
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:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:662)

该问题奇葩就奇葩在:window环境下部署完全一样的代码,运行时没有问题的;可以正常发送邮箱。

但是,部署在生产环境linux下代码完全一样,出操作系统外其他环境完全一致;就是无法发送邮件并且报如上错误。

但是这个503的错误百度和谷歌都没有找到相关的错误材料(可能是因为代码太老了,之前没有人遇到这种奇葩问题)。


通过多方测试和排查,最后给大家说下排查过程的收获(原来是mail.ar的问题):

1.之前14年的代码中为mail.jar;该jar包运行下,项目是可以正常在window环境下进行正常运行发邮件,但是无法再linux(CentOS)环境下运行报错503。

2.将代码替换新的jar包,mail-1.4.7.jar;重启项目运行后;在window环境和linux环境下都可以完美的运行,并且成功发送邮件。

还是jar包的原因,以后代码还要使用最新的jar省的有不兼容的问题出现,并且难找。


  相关解决方案