Living in Code

Ramblings from a code monkey


Testing email when working with no SMTP server

Happy New Year!

While this tip isn't my own, it still seems as though it will be very helpful.  I know that I do a lot of development locally where I don't have an SMTP server setup.  This tip, courtsey of .NET Tip of the Day, really will eliminate that problem and allow you to work with email without the headaches.

--- 

Testing code that sends email has always been a pain. You had to set up a SMTP service just to test that your .NET application sends the e-mail correctly.

However, there is a way to send e-mails with no SMTP server set up. Just configure your .NET application to drop e-mails into a specified folder instead of sending them via SMTP server:

<system.net>

   <mailSettings>

      <smtp deliveryMethod="SpecifiedPickupDirectory">

         <specifiedPickupDirectory pickupDirectoryLocation="c:\Test\" />

      </smtp>

   </mailSettings>

</system.net>

This will instruct SmtpClient class to generate mail message, save it as .eml file and drop it into c:\Test\ folder.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,
Categories: .NET
Posted by Don on Wednesday, January 09, 2008
Permalink | Comments (0) | Post RSSRSS comment feed

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

Wednesday, January 07, 2009 4:24 AM

Gravatar