Testing Email Notifications with Apache James 3.0
Join the DZone community and get the full member experience.Join For Free
On windows machines I have been using Mailster
for testing email notifications. Unfortunately, I had issues with
Mailster in the past running on non-Windows machines. Thus, on Mac I
have been using a local Postfix instance, which forwarded email to
dedicated (real) mailboxes. But, it involved a bit of customization and
ultimately I had to "know" to which mailboxes I wanted to send
However, ideally I don't really care about email addresses. Instead I typically want to verify that the format and layout of the generated emails are good, be it text emails ort Html emails. Ultimately, it would be nice, if for testing, all notification sent ended up in ONE mailbox for development testing purposes.
Enter Apache James. Not long ago I came across this wonderful blog posting below about using Apache James 2.x in order to test application email notifications:
IT is amazing to see that this is pretty much the only dedicated blog posting on the internet regarding a seemingly very common issue. You would think that almost every serious enterprise application has to sent out email notifications, and be it solely for the "forgot password" feature. What is so fantastic about using Apache James, is that it allows you to test Email notifications, while sitting on a plane with no internet in sight. Just run everything locally.
Anyway, the steps illustrated in the blog above also work nicely for James 3.0 (currently milestone 2). What is pretty cool about Apache James is that it is now Spring-based :-)
Here are the simple steps to get things set up for Apache James 3.0:
- Download Apache James 3.0
- Unzip the downloaded archive
- Edit mailetcontainer.xml in directory /conf/
- Search for "<processor name="transport">"
- Replace the entire element that starts with "<mailet match="All" class="RemoteDelivery">" with: "<mailet match="All" class="Forward"> <forwardto>test@localhost</forwardto></mailet>"
- Startup Apache James 3.0 using sudo /bin/run.sh (Sudo is needed for local permissions)
- Connect via Telnet to Apache James using: telnet localhost 4555 (User: root password: root)
- Type: adduser test test <return>
- Setup Thunderbird (or your favority email application)
Opinions expressed by DZone contributors are their own.