If you do not have a Mail Server in your environment, then this tiny little application comes very handy to test the Email functionality of your application. In this Demo post, I am documenting the step by step procedure to use SMTP4Dev with a very simple ASP.NET web application.
1) Download SMTP4Dev from Codeplex.
2) At the time of writing this blog post, the dowloaded file is smtp4dev-2.0.9-binaries.zip, which contains a small Windows Application – smtp4dev.exe (544Kb). Run this program and you will get the below screen:
3) By default smtp4dev listens on port 25. You can click on the OPTIONS button and make changes to the Port number in the Server tab.
4) In the above screen, I have entered my local domain name that I am using for testing purpose. TIP: If you are running your computer without Domain(Active Directory), then provide some dummy domain name and map the same in your HOSTS file.
5) Let us now write a Demo application in ASP.NET to test Email functionality. Here is how the Front-End of this Application looks like:
6) I have following the generic Naming standards for all the controls. And, finally below is the Code Behind for the Send Mail button click event (additionally, add System.Net and System.Net.Mail namespace at the beginning of your .CS file):
7) Let us test this application. I run this application from Visual Studio and click the Send Mail button. I click the button once again. And the result is shown below:
This completes the demo of smtp4dev. I am sure this will help you to perform quick tests of email functionality in your application.
My demo environment, that I have built for SharePoint 2010, consists of:
- Windows Server 2008 R2
- Active Directory Role and IIS Roles enabled
- Visual Studio 2010
- smtp4dev 2.0.9