This is the example project from my Web Performance Quick Wins presentation.
Here’s the slides too:
I just learned about this neat trick that’s helpful for developing email features locally.
In your web.config file you can tell your application to save emails to a folder instead of sending through an smtp server. This way you can have your application code work as normal and check all the emails it sends by just looking in a folder. The folder has to exist first. For instance, I created a local folder called c:TempEmail and then changed my local web.config to this:
<network host="smtp.address.com" password="" userName="" defaultCredentials="true" />
<!-- use a pickup directory for debugging -->
<smtp from="firstname.lastname@example.org" deliveryMethod="SpecifiedPickupDirectory">
All email sent through your application will end up as a file in the c:TempEmail folder instead of actually being sent out. And I didn’t have to change my code at all!
MailDefinition md = new MailDefinition();
MailMessage msg = md.CreateMailMessage(user.Email, replacements, bodyHtml, newSystem.Web.UI.Control());
SmtpClient smtp = new SmtpClient();
You can open the eml file in Outlook and it’ll look just like it’ll look in the real world – except that you didn’t bother your user with a test email. Sweet!