Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
... 38 more
INFO: Exception javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25;
nested exception is:
java.net.ConnectException: Connection timed out: connect
Mehul Kumbhani wrote:Thanks for your kindly reply,
But sir i hava not knowledge of how to use telnet from java and netbeans,
can you suggest me.
No, telnet is a utility application that comes with most operating systems. Assuming you're using Windows, go to Start -> Run, then enter telnet.exe smtp.gmail.com 25 and hit return. If you get a hello message from the SMTP server, then you are ale to connect. To get out, just type quit and hit return.
If, however, it hangs or gives you a connection refused error, then you are not able to connect.
I'm thinking that the telnet suggestion was not clear to the original poster, so I would like to elaborate just a bit.
The point is to debug the problem and see if the issue is with your use of the JavaMail API, or if you have a general TCP/IP connectivity issue.
The telnet application can be used to see if you are able to connect to the host/port via TCP/IP. If this doesn't work, no API which uses TCP/IP (such as Java Mail) will work either. No sense debugging Java Mail if you cannot get TCP/IP connectivity working.
I hope this make it clearer.
Were you able to connect to the GMail SMTP server host using telnet?
Mark E Hansen wrote:Were you able to connect to the GMail SMTP server host using telnet?
The answer to that question is going to be "no". Gmail doesn't use unsecured e-mail connections so it won't be listening at port 25.
And if you follow the JavaEnterpriseEditionFaq link and search for "gmail" you will find a link to what the JavaMail FAQ itself has to say about Gmail. Unfortunately, if you don't understand how e-mail works and how TCP/IP networking works, you're going to have a lot of trouble making your e-mail programs work when you have networking problems. As Mark said, no amount of looking at the code is going to help if the configuration isn't right.