Problem Description
Today I used Hutool to send text messages, using qq mailbox and smtp protocol.
Therefore, after the parameter configuration is completed, the error timeout is reported when calling as follows:
Exception in thread “main” cn.hutool.extra.mail.MailException: MailConnectException: Couldn’t connect to host, port: smtp.qq.com, 456; timeout -1
analyse problem
Obviously, this is a connection failure timeout issue.
I found the port 456 of the SMTP protocol on the Internet, but now I can’t connect. Some people on the Internet said that SSL is not turned on. Then I added it and tried it, but it still didn’t work. It still times out.
At this time, I suspected that the port was wrong. Or some parameters are missing.
Solve the problem
At this time, I searched online and found this sentence:
The QQ mailbox SMTP server address is "smtp.qq.com"
Note:
1. The SMTP server requires authentication.
2. If the SSL encryption method of SMTP is set, the SMTP server port is 465 or 587.
The port was mentioned, and then I changed the port to 587. It worked this time
Receive text message
But if you add the SSL protocol, it won't work. I don't know why.
Summarize
I really don’t understand some of the knowledge involved. Corrections are welcome and I hope it can help everyone close the gap.