Search code examples
javagrailsgroovymail-serverjames

Apache james mail server running status in Grails


we are using Apache james server with grails 2.1.1 to send and receive emails on our application.

Now we want to display an on/off icon on the page which can determine whether the James Mail Server is running or not.

So, is there a way in Java or grails to determine this.


Solution

  • You could try connecting to the remote admin port (which I believe is port 4555 by default):

    boolean jamesIsRunning = new Socket().with {
        try { 
            connect( new InetSocketAddress( 'localhost', 4555 ), 100 )
            close()
            true
        }
        catch( e ) {
            false
        }
    }
    

    Or if the remote admin port isn't open on your installation, you could try the SMTP port