dromara / hutool

🍬A set of tools that keep Java sweet.
https://hutool.cn
Other
29.25k stars 7.54k forks source link

org.dromara.hutool.extra.mail.MailException: MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 587 #3785

Closed lexang closed 2 weeks ago

lexang commented 2 weeks ago

版本情况

JDK版本: openjdk_22 hutool版本: 6.0.0(请确保最新尝试是否还有问题)

问题描述(包括截图)

rg.dromara.hutool.extra.mail.MailException: MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 587

at org.dromara.hutool.extra.mail.Mail.send(Mail.java:411)
at org.dromara.hutool.extra.mail.MailUtil.send(MailUtil.java:439)
at org.dromara.hutool.extra.mail.MailUtil.send(MailUtil.java:209)
at org.dromara.hutool.extra.mail.MailUtil.send(MailUtil.java:191)
at cn.iocoder.yudao.module.dtb.service.InfluxEntityServiceImplTest.sendMail2(InfluxEntityServiceImplTest.java:204)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)

Caused by: jakarta.mail.MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 587; nested exception is: javax.net.ssl.SSLException: Unsupported or unrecognized SSL message at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2245) at org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:729) at jakarta.mail.Service.connect(Service.java:367) at jakarta.mail.Service.connect(Service.java:225) at jakarta.mail.Service.connect(Service.java:174) at jakarta.mail.Transport.send0(Transport.java:232) at jakarta.mail.Transport.send(Transport.java:102) at org.dromara.hutool.extra.mail.Mail.doSend(Mail.java:425) at org.dromara.hutool.extra.mail.Mail.send(Mail.java:403) ... 7 more Caused by: javax.net.ssl.SSLException: Unsupported or unrecognized SSL message at java.base/sun.security.ssl.SSLSocketInputRecord.handleUnknownRecord(SSLSocketInputRecord.java:462) at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:175) at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1507) at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1422) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426) at org.eclipse.angus.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:628) at org.eclipse.angus.mail.util.SocketFetcher.createSocket(SocketFetcher.java:401) at org.eclipse.angus.mail.util.SocketFetcher.getSocket(SocketFetcher.java:214) at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2193) ... 15 more image

同样参数 用springboot mail可以

looly commented 2 weeks ago

尝试:

starttlsEnable = true

不行则再打开此issue。