java mail give java.net.connectexception: connection refused

12,336

Solution 1

You have made a spelling error! It should be "smtp.gmail.com" not "stmp.gmail.com".

Solution 2

'Connection refused' means one of two things. Either the host:port you specified is incorrect or an intervening firewall isn't playing ball.

Share:
12,336
lucky_start_izumi
Author by

lucky_start_izumi

Updated on June 13, 2022

Comments

  • lucky_start_izumi
    lucky_start_izumi almost 2 years

    I have the same code on windows and it works well. When i move the code to centos, it gives the exception: javax.mail.MessagingException: Could not connect to SMTP host: stmp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Connection refused

    Could anyone please give me some suggestion about this exception?

    Thank you very much.