Discussions

I am trying out a small application using Javamail. I have setup property "mail.smtp.host" to the smtp server using which i am able to send emails. So the server address is valid and the server is running. But still i am getting this exception as : - ========================================================== javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: < nested exception is: java.net.SocketException: Operation timed out: connect:could be due to invalid address at javax.mail.Transport.send0(Transport.java:219) at javax.mail.Transport.send(Transport.java:81) at test.OTPEmail.postMail(OTPEmail.java:85) at test.OTPEmail.main(OTPEmail.java:44)=========================================================== I am behind a firewall. Will it matter anyway?

If the mailserver is on the otherside of the FW you may not be able telnet to 25. A FW may restrict telnet. If not, try using the IP address of the mailserver. It may be a DNS or local network configuration issue.Can you ping by name & IP?

The above two suggestions will be useful if you were to set the debugging on in your code, and then follow through to the point where the exception is raised. In verbose mode, the javamail program that you write will print out each request and response provided. This is the best way to figure out where it goofs up :-).

TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.