Sending mails, development machine, without actual mail server

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

 

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.

18 thoughts on “Sending mails, development machine, without actual mail server

  1. 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!

  2. 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

  3. 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.

Comments are closed.