How to Test SMTP Emails Without a Mail Server (No SMTP Configuration Required) in ASP.NET C#

If you have ever developed an application that sends emails via SMTP you have had to deal with configuring the SMTP server on all of your environments (local development machine and production at a minimum) to test the emails.

Some of the time your local machine may not even have access to the SMTP server that your live server is accessing, which can cause your testing to be out of sync.

To get around that you can use a little tool called SMTP4Dev which is an EXE that runs on your local machine. SMTP4Dev allows you to essentially hijack emails that are being sent. All you have to do is run it, open up the options and type in your SMTP server info including host name, port, and any other necessary info. After that is configured you just run the application and trigger the emails to be sent via the SMTP server and watch as instead of being sent they are intercepted into the SMTP4Dev email list.

TIP To Test Emails With No SMTP Server at All: For local environments change your application config to point to “localhost” as the SMTP server and configure SMTP4Dev to use “localhost” to guarantee no emails will actually be sent to anyone except the SMTP4Dev application while it is running. This method also does not require an SMTP server at all.

 

Link to the screenshots of how the application looks in use: https://smtp4dev.codeplex.com/wikipage?title=Screenshots&referringTitle=Home

Leave a Reply

Your email address will not be published. Required fields are marked *