Sending mails, development machine, without actual mail server

written by Amr ElGarhy on Monday, July 20 2009

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”:

<configuration>
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="SpecifiedPickupDirectory">
                <specifiedPickupDirectory pickupDirectoryLocation="c:\email" />
            </smtp>
        </mailSettings>
    </system.net>
</configuration>
 

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.

 

Similar Posts

  1. 10+ Ways for testing website browser compatibility
  2. Websites and Web Projects
  3. Deploying ajax wcf service on shared hosting.

Comments

  • Jake Rocheleau on on 7.20.2009 at 5:00 AM

    Jake Rocheleau avatar

    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.

  • TomA on on 7.21.2009 at 11:08 PM

    TomA avatar

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

    menendez.com/.../efficiently-tes

  • Muhammad Mosa on on 7.22.2009 at 5:46 PM

    Muhammad Mosa avatar

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

  • Justin on on 7.22.2009 at 7:57 PM

    Justin avatar

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

    invalidlogic.com/.../papercut

  • Phil on on 7.23.2009 at 1:15 AM

    Phil avatar

    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!

  • Tim Gaunt on on 8.03.2009 at 11:59 PM

    Tim Gaunt avatar

    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

  • Amr ElGarhy on on 8.04.2009 at 12:12 AM

    Amr ElGarhy avatar

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

  • Italian Translation on on 8.08.2009 at 6:56 PM

    Italian Translation avatar

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

  • Kenali Dan Kunjungi Objek Wisata Di Pandeglang on on 11.03.2009 at 5:22 PM

    Kenali Dan Kunjungi Objek Wisata Di Pandeglang avatar

    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.

  • oes tsetnoc on on 11.13.2009 at 10:02 PM

    oes tsetnoc avatar

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

  • Italian to English translation on on 5.16.2010 at 6:21 PM

    Italian to English translation avatar

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

  • koleksi gambar on on 7.03.2010 at 1:27 PM

    koleksi gambar avatar

    nice blog,Thanks for your post

  • drug rehabs on on 7.07.2010 at 10:12 AM

    drug rehabs avatar

    Great read. I enjoyed reading your post and I like your take on the issue. Thanks.

  • Posicionamiento web on on 7.07.2010 at 11:14 PM

    Posicionamiento web avatar

    great post thanks

Post a comment

Options:

Size

Colors