Discussions

General J2EE: JavaMail problem

  1. JavaMail problem (3 messages)

    Hi All,

    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?

    Regards,

    Rahul.

    Threaded Messages (3)

  2. JavaMail problem[ Go to top ]

    Have you tried a telnet to your server

    i.e. telnet [smtphost] 25
     if it connects type HELO and you should get a response.

    if you cannot connect then the problem is not with your software.

    Ian Purton
    Website Uptime and Availability | Permission Email List Management | Smartphone GPS | All Time Top 100 Rock Charts
  3. 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?
  4. Debugging JavaMail[ Go to top ]

    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 :-).