Dummy SMTP servers: Papercut, smtp4dev and (n)Dumbster

It has been said that every program will grow until it can send e-mail. Today this is probably even more true than ever as the modern Internet user simply expects notices to be sent via e-mail to confirm orders, notify about shipping status or simply reset a password.

The problem with this is that it is often necessary to test software that sends e-mail. Actually sending those e-mails creates two new problems: we need to review the e-mails somehow and we run the risk of creating "noisy" software that fills someone's inbox with test data.

Enter the dummy SMTP server. The idea is simple enough: respond the same way a SMTP server would but fail to deliver the messages. Instead a dummy SMTP server provides some method for reviewing the messages.

For simple testing I like Papercut because it is a no-frills solution. Fire it up and it listens (be default) to port 25. When it receives a new message it posts them to a list where they can be inspected. The "Raw View" shows every character that Papercut received from the sender. This works very well for the initial exploratory phase of programming a new mail send.

Another contender is smtp4dev which has more comprehensive tools (you can view the session exactly as it played out), but unfortunately I found it crashed under many scenarios that already battle tested and it refused well formed e-mail addresses that real SMTP servers and Papercut had no problems with.

For unit testing, the Java world has Dumbster, which has the feature that the received e-mails can be inspected by the test code itself. There is a translation of this software called nDumbster which is a pretty literal translation and provides the same service to .NET programmers.

These tools can tame the otherwise frustrating experience of testing e-mail sending from an application.