邮件发送:Could not connect to SMTP host: 10.0.76.11, port: 25

it2024-11-12  4

这个问题咋看可能是环境配置问题,实际也有可能是ssl协议不支持的问题:

2020-10-21 15:32:16.094 [ERROR] [DubboServerHandler-10.244.2.30:17278-thread-11] - com.lls.scf.notification.service.utils.mail.MailSender-116 发送邮件 失败12345678@qq.com javax.mail.MessagingException: Could not connect to SMTP host: 10.0.76.11, port: 25         at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)         at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)         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:253)         at javax.mail.Transport.send(Transport.java:124)         at com.lls.scf.notification.service.utils.mail.MailSender.sendTextMail(MailSender.java:114)         at com.lls.scf.notification.service.service.mail.impl.NotiMailSendSerialService.sendSimpleTextEmail(NotiMailSendSerialService.java:203)         at com.lls.scf.notification.service.service.mail.impl.NotiMailSendSerialService$$FastClassBySpringCGLIB$$637731a0.invoke(<generated>)         at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)         at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)         at com.lls.scf.notification.service.service.mail.impl.NotiMailSendSerialService$$EnhancerBySpringCGLIB$$654bc6af.sendSimpleTextEmail(<generated >)                 at com.lls.scf.notification.service.provider.mail.NotiMailSendProvider.sendSimpleTextEmail(NotiMailSendProvider.java:65)         at com.lls.scf.notification.service.provider.mail.NotiMailSendProvider$$FastClassBySpringCGLIB$$2397c33c.invoke(<generated>)         at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)         at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)         at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)         at com.lls.framework.rpc.dubbo.aspect.DubboExceptionAspect.aroundMethod(DubboExceptionAspect.java:53)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.lang.reflect.Method.invoke(Method.java:498)         at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)         at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)         at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:174)         at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)         at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)         at com.lls.scf.notification.service.provider.mail.NotiMailSendProvider$$EnhancerBySpringCGLIB$$5a2cbfc4.sendSimpleTextEmail(<generated>)         at org.apache.dubbo.common.bytecode.Wrapper10.invokeMethod(Wrapper10.java)         at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)         at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:86)         at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:56)         at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)         at com.lls.framework.rpc.dubbo.filter.DubboExceptionFilter.invoke(DubboExceptionFilter.java:56)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at com.lls.framework.rpc.dubbo.filter.ProviderHolderFilter.invoke(ProviderHolderFilter.java:34)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:88)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:79)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:78)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:138)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:39)         at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)         at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)         at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:103)         at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:200)         at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)         at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)         at java.lang.Thread.run(Thread.java:745) Caused by: java.net.ConnectException: Connection refused (Connection refused)         at java.net.PlainSocketImpl.socketConnect(Native Method)         at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)         at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)         at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)         at java.net.Socket.connect(Socket.java:589)         at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)         at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)         at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:299)         at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:208)         at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927)         ... 62 common frames omitted

解决办法:

1、排查邮件配置问题,域名,用户,密码,端口问题;

2、排除是否支撑ssl协议:

添加配置: //是否开启发送邮件的功能 @Value("${lls.notification.smtp.email.ifSSL}") private boolean ifSSL; /** * 获得邮件会话属性 */ public Properties getProperties() { Properties p = new Properties(); p.put("mail.smtp.host", mailServerHost); p.put("mail.smtp.port", mailServerPort); p.put("mail.smtp.socketFactory.fallback", "false"); p.put("mail.smtp.auth", validate ? "true" : "false"); // p.put("mail.smtp.localhost", "127.0.0.1"); // Linux下发送邮件报 // javax.mail.MessagingException: // 501 Syntax: HELO hostname if(ifSSL){ p.put("mail.smtp.socketFactory.port", "465"); p.put("mail.smtp.socketFactory.class", SSL_FACTORY); } return p; }
最新回复(0)