Testing Email Messages Sent using System.Net.Mail on Windows Vista

I've been developing for months on Windows Vista and had everything I needed at my disposal.  Last night, however, I needed to test whether or not email messages were being successfully sent from an ASP.NET application and see what they looked like.  I went to look for an SMTP server in Vista Ultimate and quickly found that there isn't one.  IIS7 includes email forwarding capabilities, but I wanted a simple SMTP server (or something that could emulate one) so that I could see the email messages that were being sent. 

After doing a little research I found a few programs that fit the bill for testing email sent from applications running on Vista.  The first is a free program called "Free SMTP Server" that Steve Schofield blogged about awhile back.  You can read Steve's post about the application here:

http://blogs.orcsweb.com/steve/archive/2007/09/08/vista-and-an-smtp-server-on-port-25-or-587.aspx

Here's what the program looks like while running (it's a stand-alone program rather than a service which actually worked out well for my situation).  It allows you to configure the DHCP server and the port that's used which is nice if your ISP blocks port 25.

image

The second program was actually even better for my current testing purposes since I really didn't need an SMTP server installed.  I needed to see what the actual email messages that were sent looked like to make sure data was formatted properly.  The program's called "Antix SMTP Server for Developers" and can be found here:

http://channel9.msdn.com/ShowPost.aspx?PostID=281695#281695

image

This program isn't actually an SMTP server (more of an emulator), but it captures any messages sent to port 25 and stores them in a folder.  You can then view the messages directly to make sure they contain the information you were looking for while testing. 

There are obviously a lot of full-blown SMTP servers out there that would work, but for testing purposes these two programs did the job for me.

Update:  David Findley posted something that I hadn't thought of using that's even easier.  Adding this to web.config will dump email messages sent from an ASP.NET application to the specified path:

<system.net>
  <mailSettings>
    <!--
    Production setting
    
    <smtp deliveryMethod="Network">
      <network host="localhost" port="25" />
    </smtp>
    
    -->

    <smtp deliveryMethod="SpecifiedPickupDirectory">
      <specifiedPickupDirectory pickupDirectoryLocation="C:\TestMessages" />
    </smtp>

  </mailSettings>
</system.net>

comments powered by Disqus

1 Comment

  • Nice! I especially like the "Antix SMTP Server for Developers" route since I also do a lot of PHP development along with my ASP.NET and need the same functionality when working in that environment.

Comments have been disabled for this content.