RSS RSS feed | Atom Atom feed
Popular Articles: Tom Riddle's Magical Diary | AJAX Lego Robot | AJAX CAPTCHA | SQL Multisets

GreenMail v1.0 Released

More often a rule than an exception, many of the applications we write, the application needs to send or retrieve emails using SMTP, POP3 or IMAP.

Being an admirer of Extreme Programming I liked to write test for the emailing logic. I first started using Dumbster for SMTP testing, but found it bulky to use with non-easy-ways to do things. For example, to retrieve an email, one has to create an iterator and iterate you way to the email ordinal in question (all with ugly scaffolding code around it). Why can’t I simply just get, say, an array back, which is dead easy to index? Beats me. Anyway, looking at it from the bright side GreenMail helped clean up our test code quite a bit.

Apart from the shortcomings of Dumbster, our application required a library that could support SMTP, POP3, IMAP, SMTPS, POP3, and IMAPS with configurable user accounts and credentials. Dumbster is only for testing SMTP with no user account support. Further, looking into Dumbster's source code reveals polling wait statements which appears to have caused various exceptions of the following kind

java.net.BindException: Address already in use: JVM_Bind
forcing us to implement tricky wait wrappers.

 

Since there were no open source library available to do the job on the other protocols, and since the world could need a email test server library, work began on GreenMail. A couple of weekends later GreenMail was born (30 minutes ago that is). My hope is that developers, QA and other people will find it a valuable and easy-to-use tool in their testing efforts.

I'd love to hear any feedback! Good or bad. Mostly bad so GreenMail can improve and take over the world, wahahahaha....

Oh, by the way, here is the link to GreenMail

slashdot digg del.icio.us technorati [more]



Re: GreenMail v1.0 Released

I noticed when running multiple test cases that I would get "address in use JVM_BIND" errors. Adding a Thread.sleep seems to help things. My tearDown method now looks like this:

protected void tearDown() throws Exception {
super.tearDown();
if (servers != null){
servers.stop();
Thread.sleep(5);
}
}

Re: GreenMail v1.0 Released

It seems the world could use a Java IMAP server. Any tips on how to take this code and make it a somewhat functional IMAP server with a real (e.g. maildir) message store? Also, have you tested this code with the IMAP reference client? The IMAP author is pretty touchy about who calls what servers "IMAP servers". He's a tool. Thanks!

Re: GreenMail v1.0 Released

Hi Matt, I would probably start with the implementation from the james project and use greenmail whenever james has some bugs etc (if applicable of course). GreenMail's original IMAP code comes from james.

Re: GreenMail v1.0 Released

<p class="MsoNormal">I too am getting the JVM bind errors and my test execution hangs. Adding the a Thread.sleep() kept it from hanging but I still get the error for each test that gets executed after the first.

If any one was able to get around this please let me know.

Re: GreenMail v1.0 Released

Hi Lake,
Are you calling servers.stop() ?

Re: GreenMail v1.0 Released

yes, my tearDown metod looks like this:

protected void tearDown() throws Exception
{
     super.tearDown();
     if (servers != null){
        servers.stop();
        Thread.sleep(5);
   }
}

Thanks!

Re: GreenMail v1.0 Released

Hi Lake, if you dont mind sending me your testcase wtih some stubs i'll perhaps be able to reproduce things.

Add a comment Send a TrackBack