JavaMail 发送邮件出现 Connection reset 问题
作者:互联网
问题描述
使用 java mail 发送邮件的时候,申请的 163 邮箱作为发件箱,然无论如何配置,均出现 Connection reset,无法正常发送邮件。
Exception in thread "pool-2-thread-1" cn.hutool.extra.mail.MailException: MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465
at cn.hutool.extra.mail.Mail.send(Mail.java:229)
at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:211)
at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:175)
at com.shulipeng.common.service.impl.MailServiceImpl.sendMail(MailServiceImpl.java:57)
at com.shulipeng.activiti.listener.MyEventListener.sendMail(MyEventListener.java:134)
at com.shulipeng.activiti.listener.MyEventListener.lambda$notify$0(MyEventListener.java:93)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 465;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2211)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at cn.hutool.extra.mail.Mail.doSend(Mail.java:241)
at cn.hutool.extra.mail.Mail.send(Mail.java:227)
... 8 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:620)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:394)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:218)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2175)
... 16 more
问题解决
相同的代码,用公司的网络不能正常发送,用自己手机发出来的热点可以发送,原因是因为被墙了
标签:reset,java,Service,sun,Connection,JavaMail,mail,com,SSLSocketImpl 来源: https://www.cnblogs.com/shulipeng/p/12857390.html