Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I don't know where the problem is but I am using netbeans 6.9.1 with tomcat 6.0.2 and have a mail lib trying to send an email but gives me an error on the method: Transport.send( message );
sendEmail(sSMTP, sFrom, sEmail, sSubject, sMessage);
and on the webpage it gives me:
Could not connect to SMTP host: <hostname>, port: 25</hostname>
Can you please give any advices.
It gives me an exception on Netbeans/ tomcat:
MSIL
javax.mail.MessagingException: Could not connect to SMTP host: <hostname>, port: 25;
  nested exception is:
        java.net.ConnectException: Connection refused: connect
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
        at javax.mail.Service.connect(Service.java:288)
        at javax.mail.Service.connect(Service.java:169)
        at javax.mail.Service.connect(Service.java:118)
        at javax.mail.Transport.send0(Transport.java:188)
        at javax.mail.Transport.send(Transport.java:118)
        at tracking.DBQuery.sendEmail(DBQuery.java:1821)
        at tracking.DBQuery.resetPassword(DBQuery.java:1354)
        at org.apache.jsp.resetpassword_jsp._jspService(resetpassword_jsp.java:80)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
        ... 30 more</hostname>
Posted
Updated 24-Jun-11 1:59am
v3
Comments
Richard MacCutchan 24-Jun-11 9:19am    
Are you sure your configuration is correct, and your SMTP host is actually listening for mail request connections?

The connection is refused.

Please check your email-server. They sometimes have a 'ban' function. It does what it's supposed to do - it bans you with a certain number of false login attempts.

This can be really annoying, specially while development.

Also check if there are "rules" set up during ban, some handle the ban as a simple limited time rule for the server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900