File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Could not open connection to the host, on port 25: Connect Failed. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Could not open connection to the host, on port 25: Connect Failed. " Watch "Could not open connection to the host, on port 25: Connect Failed. " New topic
Author

Could not open connection to the host, on port 25: Connect Failed.

raja selva
Greenhorn

Joined: Jul 14, 2010
Posts: 6
Hi all,

I am trying to do java mail application through connecting hmailserver .But whatever code i am deploying/executing its showing exception like could not connect to smtp host:xxxxxxx" port:25 nested exception is:java.net.ConnectionException: Connection refused:connection


when I try the command in client machine telnet machinename 25 or telnet <ip address> 25 it is working fine. But i am not able to connect via java.

please help me.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Does the error message clearly indicate that the host that javamail is trying to connect to is the actual SMTP server host?


[Jess in Action][AskingGoodQuestions]
raja selva
Greenhorn

Joined: Jul 14, 2010
Posts: 6
Hi,

Thanks for your reply.

Please find the below error message,

javax.mail.MessagingException: Could not connect to SMTP host: 10.138.142.213, port: 25;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at SendMail.send(SendMail.java:62)
at SendMailTest.main(SendMailTest.java:25)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 8 more
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not open connection to the host, on port 25: Connect Failed.