How to use java to send e-mail when port 25 of alicloud server is disabled (solve the problem of disabling port 25)

Usually, we use java to send mail locally. There is usually no problem, but if we deploy to the server, we may encounter problems. Of course, this has something to do with operators. For example, I bought a virtual machine on the coffee host before deploying my personal website. There is usually no problem and there are not so many restrictions.

However, there are many restrictions on Alibaba cloud. For example, if the entrance direction of the port is not opened, some software installed on the server, such as the commonly used tomcat, may not be used.

First, the port is not open, and second, there is a problem with the white list setting.

Today, let's talk about how to solve the problem of disabling port 25 of alicloud server and successfully send mail. First, paste the complete code, as shown below:

The key lies in this:

I use the mail package to rely on the following:

In addition, if you want to confirm whether the port on your server is available, you can use this command (in this way, you can save time and improve efficiency by deploying to the server):

If the server returns such a result, it is as follows (generally indicating that it is available):

If this is the result, it usually means that it is unavailable (it is usually stuck in trying, and then the server may try trying again, but it is still useless):

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>