简体   繁体   中英

Java Mail Error : java.net.ConnectException: Connection refused: connect

I am stuck with the mail sending with Java Mail API.

I am not able to connect SMTP server with any kind of properties... I have tried with different combination.

I am connecting SMTP Remote server (Server is not at localhost, its in LAN), with port 25 but it gives me the port error to 465, I dont know why ?

javax.mail.MessagingException: Could not connect to SMTP host: *RemoteIP*, port: 465; nested exception is: java.net.ConnectException: Connection refused: connect 

If anyone can help.

Thankx in advance.

Maybe your mail server is actually using SMTPS on port 465 (although it's not the recommended port). If that is the case you can see here an example of using JavaMail with SMTPS. Note the property mail.smtps.host ; you also have the mail.smtps.port property to specify 465.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM