Sending mails, development machine, without actual mail server

//Sending mails, development machine, without actual mail server

Sending mails, development machine, without actual mail server

By |2009-07-20T01:42:00+00:00July 20th, 2009|Categories: Technical|18 Comments

email1

During development, you might prefer just to write mails to a local directory, so you can see what’s
happening without having to set up an actual mail server.

To do that open web.config and add these few lines “instead of real SMTP configurations, which you will need to activate on the real server and delete/comment these lines”:

<span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">configuration</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">system.net</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">mailSettings</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">smtp</span> <span style="color: rgb(255, 0, 0);">deliveryMethod</span><span style="color: rgb(0, 0, 255);">=&quot;SpecifiedPickupDirectory&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">specifiedPickupDirectory</span> <span style="color: rgb(255, 0, 0);">pickupDirectoryLocation</span><span style="color: rgb(0, 0, 255);">=&quot;c:\email&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span>
<!--</span--><span style="color: rgb(0, 0, 255);"><span style="color: rgb(128, 0, 0);">smtp</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<!--</span--><span style="color: rgb(0, 0, 255);"><span style="color: rgb(128, 0, 0);">mailSettings</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<!--</span--><span style="color: rgb(0, 0, 255);"><span style="color: rgb(128, 0, 0);">system.net</span><span style="color: rgb(0, 0, 255);">&gt;</span>
<!--</span--><span style="color: rgb(0, 0, 255);"><span style="color: rgb(128, 0, 0);">configuration</span><span style="color: rgb(0, 0, 255);">&gt;</span></span></span></span></span>
 

This will write .eml files to the specified folder (here, c:\email), which must already exist and be
writable. If you double-click .eml files in Windows Explorer, they’ll open in Outlook Express or Windows Mail.

 

 

Tim Gaunt in his below comment mentioned about a very nice tool called smtp4dev , A Dummy SMTP server that sits in the system tray and does not deliver the received messages. Useful for testing/debugging software that generates email.

About the Author:

Senior Software Engineer.

18 Comments

  1. Jake Rocheleau 20th July 2009 at 5:00 am

    This is great, I’ve got IIS set up on a laptop in my room but can never figure out how to configure an SMTP client.

  2. TomA 21st July 2009 at 11:08 pm

    For Django apps I have used smtp_sink.py with the same effect.

    menendez.com/…/efficiently-tes

  3. Muhammad Mosa 22nd July 2009 at 5:46 pm

    Cool tip Amr, and really nice blog you made a good job with graffiti

  4. Justin 22nd July 2009 at 7:57 pm

    I use a free product called Papercut that acts like a local SMTP server but doesn’t send out the messages.

    invalidlogic.com/…/papercut

  5. Phil 23rd July 2009 at 1:15 am

    That’s fantastic. It will no doubt come in handy for live envionments too – useful for queuing mail, logging, error handlers, you name it!

    I’ve already added it to an email utility function which allows email to be globally disabled or put into 1 of 3 (now 4) test modes. 0 = Normal, 1 = Bcc test address, 2 = test address only only, 3 = SaveToPath, 4 = Disabled.

    Thanks for the post. I wonder how many other gems like this .net has hidden away!

  6. Tim Gaunt 3rd August 2009 at 11:59 pm

    I’ve used this and Papercut in the past however we’re now using smtp4dev which is a step on from both as the issue we had was viewing the emails themselves.

    smtp4dev can be found here: http://smtp4dev.codeplex.com/ aparently v2 is on it’s way too…

    Tim

  7. Amr ElGarhy 4th August 2009 at 12:12 am

    @Tim Gaunt, Thanks for sharing this nice tool, will mention about in the post body, because its an important tip.

  8. Italian Translation 8th August 2009 at 6:56 pm

    Thnaks mate,I was looking for that info nearly 2 days.You made my mails lot easier

  9. Kenali Dan Kunjungi Objek Wisata Di Pandeglang 3rd November 2009 at 5:22 pm

    I havent any word to appreciate this post…..Really i am impressed from this post….the person who create this post it was a great human..thanks for shared this with us.

  10. oes tsetnoc 13th November 2009 at 10:02 pm

    Great blog, this could be the best blog I ever visited this month. Never stop to write something useful dude!

  11. Italian to English translation 16th May 2010 at 6:21 pm

    That’s a very neat method for sending mails without an email server,

  12. fix computer freezes and slow startup 11th August 2010 at 7:27 am

    Good trick from you. THanks mate, I’ll use this as my future reference.

  13. term paper 29th September 2010 at 1:34 pm

    smtp4dev is an excellent tool for quick, easy email testing. I can’t believe how easy it was to specify localhost as my email server in web.config, launch smtp4dev, and start testing the notification process for a data-driven app I’m working on. I can see who all will get notifications at a glance without spamming them with test mail.

  14. Aldi 7th October 2010 at 10:00 am

    I’m still dont understand, but thanks for sharing

  15. Term paper 8th February 2011 at 6:49 pm

    I like your post!I didn’t know about tool smtp4dev,thanks, it is really helpful.

  16. lean blog 25th February 2011 at 8:18 pm

    I do not know that that is possible. Actually we are using mail server as of the moment.

  17. keyboard case for the ipad 6th June 2011 at 3:53 am

    This seems to be a good option if you are sending out mass emails from just one server. I need to show this to my boss for approval.

  18. gel fuel fireplace 17th June 2011 at 2:09 am

    I think I need this one. I do have a question, is this also possible if I am using a free email account? Like Yahoo or Gmail?

Comments are closed.