> don_kitchen
// TODO: write witty tagline
← cd ..

Testing email when working with no SMTP server

Β·1 min read
━━━

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&gt;

<mailSettings&gt;

<smtp deliveryMethod="SpecifiedPickupDirectory"&gt;

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

</smtp&gt;

</mailSettings&gt;

</system.net&gt;

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