.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Configuring Email for Development Server

Posted By:Jean Paul       Posted Date: September 27, 2013    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we shall explore how to configure email server for a development machine and use smtp4dev tool to capture the emails generated from the machine in SharePoint

In this article we can explore how to configure Email for Development Server.  In real world development scenarios you need to work with Email enabled lists / workflows / code. 


Your customer reported a problem with Email sending from a web part you have developed.  You need to ensure the piece of code works fine in your development machine.  As there is no email server configured in your machine - How to test this code?


We can set up a Development Server with emailing enabled.  Setting up Email for the Development Server along with a Receiver tool you can ensure that emailing code is working perfect.


Following are the steps involved:
1.  Configure outgoing SMTP server
2.  Set Email property for User Profiles
3.  Install smtp4dev tool
4.  Test Email Code
Please note that I am using a Windows 7 64-bit machine for working with this.  The same configurations should work for Windows Server development machine.

Configure outgoing SMTP server

Open Central Administration and click on the System Settings category from the left.

In the appearing page click on the Configure outgoing e-mail settings link highlighted above.  You should get the page given below.

Enter the Outbound SMTP server as your machine name.  Please enter a name instead of IP Address or localhost.
Enter the From and Reply-To address.
Click the OK button to save the changes.

Set Email property for User Profiles

As the next step we need to set the user profile property E-mail for testing the feature.  You can set this through:
1.  My Profile of each user
2.  Central Administration for all users
Let us use the Central Administration way as we can set for multiple users.  Open Central Administration > Manage service applications > Select User Profile Service Application > Click Manage button from toolbar.

In the appearing page click on the Manage User Profiles link as highlighted below:


In the appearing page search for user and from the result choose Edit menu item.


In the Edit profile page set the Work-email property and save changes.

Install smtp4dev tool

Now we can try installing the smtp4dev tool (a wonderful tool) that captures the Port 25 of your machine.  You can download the tool from following location:

 the Download button on the appearing page.

Run the downloaded file and you should see the following screen.

By default the tool started to listen on Port 25.  You can minimize the tool and it is available in the system tray.
Note Running another instance of the smtp4dev tool cannot listen to the same port 25.  You need to invoke the previous copy of the tool from system tray to view any email messages.

Test Email Code

Now we are ready to test the email code.  Start a new SharePoint Console application, change the project properties to .Net Framework 3.5 and replace the Program class content with following code.


using System.Collections.Specialized;
class Program
  static void Main(string[] args)
  using (SPSite site = new SPSite("http://localhost"))
  StringDictionary messageHeaders = new StringDictionary();
  messageHeaders.Add("to", "to@server.com");
  messageHeaders.Add("cc", "cc@server.com");
  messageHeaders.Add("from", "from@server.com");
  messageHeaders.Add("subject", "Email Subject");
  messageHeaders.Add("content-type", "text/html");

  SPUtility.SendEmail(site.OpenWeb(), messageHeaders, "Email Body");


For the time being we are using dummy email address.  Try executing the code.  You can see the email being captured by smtp4dev tool.





In this article we have explored how to configure email server for a development machine and use smtp4dev tool to capture the emails generated from the machine.  You can use the same configuration to test other emails through Workflows, Web Parts etc. that are generated through SharePoint.

Please note that here we are setting up a development machine email server and for configuring the actual email service you need to check the link from References section.

 Subscribe to Articles


Further Readings:

Author: nistelroi         Company URL: http://www.dotnetspark.com
Posted Date: May 17, 2014

Also may be use FakeSMTP for email testing
Good alternative

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend