Development SMTP Servers for IIS7.5 on Windows 7

Development SMTP Servers for IIS7.5 on Windows 7

Published on: Tuesday, April 6, 2010 3:43:00 PM)

I've had one of them days. You know? That "simple task" that spiralled out of control and resulted in me losing half a day to it's tricks! That task? It was sending an email from an ASP.NET (MVC2) application. Previously, I've always done this via setting up IIS and the SMTP server in there, but for some reason, Microsoft decided they didn't want to include the SMTP Server in Windows 7 anymore (even 'Ultimate' - it might also be the case for Windows Vista). So, I had to find an alternative.

There were a few options available to me:

The last one is the one I eventually choose and boy am I glad I did! I downloaded the excellent SMTP 4 DEV from Codeplex

Here is some fake code that should send an email to the localhost.

MailMessage emailMessage = new MailMessage();
string messageBody = "This is the content of the email will be awesome!";
emailMessage.Body = messageBody;
emailMessage.Priority = MailPriority.Normal;
emailMessage.From = new MailAddress(""); // obviously, this email address doesn't exist :)
emailMessage.Subject = "The answer is 42";
emailMessage.IsBodyHtml = false;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Host = "";  // localhost
mSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;