我的应用程序在aws EC2上发送电子邮件非常好,突然它开始抛出异常
javax.mail.MessagingException'.
javax.mail.AuthenticationFailedException: 535 5.7.8 Error: authentication failed: authentication failure
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at com.server.utils.EmailServicesImpl.sendMail(EmailServicesImpl.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:110)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.lang.Thread.run(Thread.java:745)
这是我的电子邮件设置
mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.smtp.host=smtp.mydomain.in
mail.smtp.port = 587
我也试过了port 25
,但问题仍然存在。
答案 0 :(得分:2)
根据您的设置,您需要StartTLS。它的默认端口是587,这很好;把它改成25肯定会打破它。
您的错误消息指出authentication failed
,因此我怀疑您要么不提供凭据,要么提供错误的凭据。