Simple email testing with SMTP SpecifiedPickupDirectory

ASP.NET MVC,Testing 16 April 2012 | 0 Comments

I often found myself messing around with test email accounts and manually checking these accounts and worrying about sending an actual customer an email.

A super simple way to develop an ASP.NET project locally and not even use an actual SMTP server is to take advantage of ASP.NET SMTP’s “SpecifiedPickupDirectory” option.

Using this, an actual SMTP server isn’t used and emails are saved to disk which can be opened and viewed using Outlook.

Super simple email testing!

Works without an internet connection, no real email accounts needed, no worry about sending actual emails to customers!

When pushing or deploying, use a Web.config transformation to replace the testing SMTP section with actual production values.

Kudos to @swaj who wrote the excellent Nuget package ActionMailer and first showed me this technique. By the way, ActionMailer is awesome as you can use the Razor engine and views to make your email templates!

Leave a Reply