[Solved] JAVA Mail Sent Error: Sending the email to the following server failed

Htmlemail uses QQ corporate email to send problem summary

After the local mail sending test is passed according to the parameter information on htmlemail, deploy the service on the ECs to test the mail sending. The first error is reported:

Sending the email to the following server failed : smtp.exmail.qq.com:25

Ping smtp.com directly on the ECS exmail. qq. COM domain name found that the external network on the server is not connected. After opening the external network permission, the above error still exists.
browse the document and try to switch smtpport to port 465:

HtmlEmail.setSmtpPort(465);

Error still reported:

Sending the email to the following server failed : smtp.exmail.qq.com:465
Could not connect SMTP host:smtp.exmail.qq.com, port 465, response: -1

It is found that sslonconnect needs to be set to true when switching to port 465

HtmlEmail.setSSLOnConnect(true);

After modification, the error information is changed to:

Invalid address

Finally, switch smtpport to 587:

HtmlEmail.setSmtpPort(587);

Finally, no error is reported. Record it for review later.

Read More: