How to develop and test an app that sends emails (without filling someone's mailbox with test data)?

Language AgnosticEmailTestingSmtp

Language Agnostic Problem Overview


I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages.

In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution.

I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever.

But surely such a tool already exists? How do you test sending email?

Language Agnostic Solutions


Solution 1 - Language Agnostic

I faced the same problem a few weeks ago and wrote this: http://smtp4dev.codeplex.com

> Windows 7/Vista/XP/2003/2010 compatible dummy SMTP server. Sits in the system tray and does not deliver the received messages. The received messages can be quickly viewed, saved and the source/structure inspected. Useful for testing/debugging software that generates email.

Solution 2 - Language Agnostic

A few ago I came across the following solution for the .NET platform.

<system.net>
  <mailSettings>
    <smtp deliveryMethod="SpecifiedPickupDirectory">
      <specifiedPickupDirectory pickupDirectoryLocation="C:\TestMailMessages\" />
    </smtp>
  </mailSettings>
</system.net>

Simply place the above code in your App.config or Web.config. When you send a message now it will be stored as a file in the directory you provided as "pickupDirectoryLocation". Works like a charm.

Solution 3 - Language Agnostic

There is now a web based version of Papercut.

Also the app based version works fine for me.

Solution 4 - Language Agnostic

Dumbster might be what you want then. It's an open source fake SMTP server written in Java. It takes the place of a real SMTP server, so you can test your app in a realistic setting, without having any code stubbed out. You can make sure the right messages are sent to the SMTP server without actually delivering messages.

Solution 5 - Language Agnostic

This is similar to the smtp4dev except implemented in java so it works for non-windows developers.

http://www.aboutmyip.com/AboutMyXApp/DevNullSmtp.jsp

Solution 6 - Language Agnostic

There is also Papercut and Neptune, too bad none of these can be run in a portable way.

Solution 7 - Language Agnostic

I've been using "Test Mail Server Tool" from ToolHeap for years.

http://www.toolheap.com/test-mail-server-tool/

It is a simple app that runs in your system tray and dumps emails to a folder. It can also be configured to open each email in your default mail program.

Solution 8 - Language Agnostic

if you are using java I would use Wiser: Wiser is a simple SMTP server that you can use for unit testing applications that send mail.

Solution 9 - Language Agnostic

You can also use netDumbster.

http://netdumbster.codeplex.com/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPatrick McElhaneyView Question on Stackoverflow
Solution 1 - Language AgnosticrnwoodView Answer on Stackoverflow
Solution 2 - Language AgnosticJoopView Answer on Stackoverflow
Solution 3 - Language AgnosticAdam SeabridgeView Answer on Stackoverflow
Solution 4 - Language AgnosticFredouView Answer on Stackoverflow
Solution 5 - Language AgnostictxyojiView Answer on Stackoverflow
Solution 6 - Language AgnosticAlix AxelView Answer on Stackoverflow
Solution 7 - Language AgnosticAdrian ClarkView Answer on Stackoverflow
Solution 8 - Language AgnosticPersimmoniumView Answer on Stackoverflow
Solution 9 - Language AgnosticCarlos MendibleView Answer on Stackoverflow