views:

2967

answers:

9

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?

+4  A: 

Dumbster might be what you want then. It's a fake SMTP server written in Java

Fredou
updated my answer
Fredou
A: 

The problem with sending SMTP messages is that there're many documents covering SMTP and being compliant to any one of them is not enough. You need to collect enough data about what SMTP server typical implementations exist so you can handle all possible interactions.

That's why having one SMTP server is not of great use.

sharptooth
I'm not testing the SMTP client. I know it works. I'm developing things like web site shopping carts that send receipts to the user. I'm really concerned that the discount is applied correctly, but I can't run the code without sending an email.
Patrick McElhaney
Though occasionally I do want to see the message that was sent.
Patrick McElhaney
+15  A: 

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

Robert Wood
+1 A little buggy but overrall does what its needed for. Thanks!
David
+4  A: 

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

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

txyoji
+1  A: 

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

Alix Axel
I finally got around to trying these. Unfortunately, both keep crashing.
Patrick McElhaney
Just tried Papercut. Works great and has the bonus feature of being able to view the email right in the UI.
Jeremy Wiebe
+2  A: 

there is now a web based version of Papercut: http://dummysmtp.com also the app based version works fine for me.

+4  A: 

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>

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.

Joop
+1  A: 

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.

raticulin
+1  A: 

You can also use netDumbster.

http://netdumbster.codeplex.com/

Carlos Mendible