Testing E-Mail Functionality
One of the most common questions I see on ASP.NET forums relates to sending E-Mail. I have addressed many of those issues already, so I wont get into how to send E-Mail from an ASP.NET web site.
This week I have been working on testing applications and had a chance to meet Donovan Brown of Notion Solutions. Donovan is all about testing and has some fantastic tools to test all aspects of applications and is a Team System freak!! This afternoon I was having a great conversation when he mentions he created a little SMTP server to test E-Mail functionality called Neptune.
All you need to do is download Neptune from Donovan’s Blog, run the installer and then run Neptune whenever you need an SMTP server to receive E-Mail sent from your application.
You can either explicitly set the SMTP server in the SMTPClient or in the web.config to ‘localhost’ or ‘127.0.0.1’ and E-Mail will be sent to Neptune. It does not really process the message, only consumes it. So it does not relay the message anywhere and you do not have to have a preset E-Mail address configured. It is really point and shoot. Each time a message is sent to Neptune it increments the Messages count. It can be reset at anytime or stopped. Stopping the SMTP server is important to make sure you application fails gracefully when it cant reach the destination SMTP server.
Neptune supports commands from RFC 821 and 2821; HELO, EHLO, MAIL, RCPT, DATA, NOOP, RSET and QUIT. It also stores the messages in memory so you can interrogate them with your testing framework, like a Visual Studio Web Test. There is also accompanying plug-in, extraction and validation rules included with Neptune.
Port 525 is used for administrative purposes. There is complete documentation included with the installation that details everything about administrating the server, testing, etc.
What Neptune isn’t or does not do, well relay E-Mail for one. It does not simulate response codes from the destination server. For example lets say the message was not delivered because the destination address does not exist or their inbox is full.
Despite those limitations I think this is a must have for software developers to have on their development machines. Even though I have my own mail server at my disposal I really like the idea of having my own little SMTP test server.