We’ve recently added email notifications to our application. I really wanted to avoid configuring email servers or setting up email accounts to test our software. Luckily there are a number of tools to help with this for development, and testing.
We’re using .Net so we can configure our application to send all SMTP to a file directory. This can be done in the application configuration file with the below snippet;
<system.net> <mailSettings> <smtp deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="c:\temp\mailbox\"/> </smtp> </mailSettings> </system.net>
Our acceptance tests relied on this mechanism to redirect SMTP traffic to the file system. We then had an interface in our automation framework to parse these files so we could easily check the contents.
For manual testing we wanted to avoid having to change the application configuration so looked for a simple way of setting up SMTP.
I use SMTP4Dev simply because I’ve used it before but will try papercut when I get some time.
This is the only time we needed to have a real SMTP server configured. For this we have a Dogfood environment that our operations department takes care of. Taking this approach completely removed the need to become experts in configuring email servers to test sending emails.