Results 1 to 5 of 5
  1. #1
    sandeep.ctg is offline Member
    Join Date
    Mar 2010
    Posts
    7
    Rep Power
    0

    Post Check SMTP server status

    Hello all,

    i have a java program to send emails working fine. But now before sending a email i want to ensure that my mail-server is up and running. So how do i get the smtp server status. That should be platform independent:confused::confused:

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Did you read JavaMail API?

    You don't want to actually send the email, you can open a TCP socket to port number 25 of your mail server and send the separate commands to subject, mail from/to. Something like this,

    TestMail your_domain.com
    From: youre_mail@your_domain.com
    To: recipient@recipient_domain.com

    And then check each response. If you didn't get any error, means that your mail server is working fine.

  3. #3
    sandeep.ctg is offline Member
    Join Date
    Mar 2010
    Posts
    7
    Rep Power
    0

    Default

    Actually i want to send email using JavaMail API but before that i just want to have a method which returns true/false depending on the smtp server status.

  4. #4
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    You can send mail as 2 step process.

    1. step - connect to server
    2. step - send message

    On first step:
    "Usually, when you get a low level SocketException when connecting, the problem is due to your networking configuration. Usually it's not a Java problem." (from JavaMail API FAQ)

    So don't use ordinary
    Transaport.send ()

    try different connection problems scenarios and use something like this:
    Java Code:
     Transport t = session.getTransport(protocol);
        try {
            t.connect(username, password);
       }    catch(SocketException e){
    }
     
    try {
    
    t.sendMessage(msg, msg.getAllRecipients()
    
    } catch(Exception e) {}

    and be sure u use
    Java Code:
    session.setDebug(true); // Verbose!
    in your code when performing this tests!

    regards
    Last edited by FON; 04-01-2010 at 11:43 PM. Reason: more comments

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by sandeep.ctg View Post
    Actually i want to send email using JavaMail API but before that i just want to have a method which returns true/false depending on the smtp server status.
    Did you try what I've suggest to you? Using that you can build a method as you want to see in your code. Give a try and see.

Similar Threads

  1. Replies: 2
    Last Post: 08-24-2011, 04:32 PM
  2. Check SMTP server status
    By sandeep.ctg in forum Java Servlet
    Replies: 0
    Last Post: 03-31-2010, 08:10 AM
  3. Check LAN connection status through JAVA
    By shanmathi in forum Advanced Java
    Replies: 1
    Last Post: 04-09-2009, 03:19 PM
  4. smtp server configuration with jboss server
    By vilas_patil in forum Java Servlet
    Replies: 0
    Last Post: 01-05-2009, 01:18 PM
  5. Readind email from smtp server
    By pzkhan in forum Advanced Java
    Replies: 0
    Last Post: 02-10-2008, 07:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •