views:

905

answers:

11

I am writing a program that will be emailing reports out many (~100) clients which I want to test before I spam everyone.

I want to do a test run against my production data and actually send the messages to a SMTP server, but I don't want the SMTP server to actually deliver the messages. I want the server to act like a real SMTP server from the perspective of my application, but instead of delivering messages, I just want it to store the messages, and log what happened.

Is there a SMTP server specifically designed for testing purposes?

Does anyone know of a way to configure exim or postfix to behave like I have described above

What do you use to test a mass-email delivery?

A: 

I personally modify the e-mail addresses to test, I send them to a dummy account of mine, that way I can validate not only that they sent, but that they appear in the proper format.

Mitchel Sellers
+7  A: 

In java you can use dumpster

Its easy to use and you can validate every aspect of the email you are intercepting.

It's a Java SMTP server implementation meant for unit testing. (Just make sure you redirect your email to the machine running dumbster...)


I just found another alternative that do almost the same: Greenmail

Greenmail also support POP3, IMAP with SSL so you can test your client against it.

Frederic Morin
Wow! Thank you so much. Just want I've always needed!
Hates_
Nice! Thanks!What about accepting this answer as the best one?
Brian Clozel
+2  A: 

http://skaraarslan.blogspot.com/2008/02/how-to-check-email-works-without-using.html

(this presumes you are using .net to send emails)

dove
A: 

At my office, we have a server that is set up to always send all incoming mail to one address, regardless of who it's actually addressed to. We just point all our testing environments at that server and watch the QA mailbox fill up. I don't know what server it is, but it's probably some open source thing someone found.

rmeador
+2  A: 

Given that you mention exim and postfix (which I'm taking to be some kind of unix stuff), this answer might not be as useful as it could be, but check out Neptune. It's a fake SMTP server designed for automated testing. If you've got a spare windows box floating around, you could put Neptune on that then configure your app to send "through" the Neptune server.

Dan F
A: 

Sendmail has a Test Mode.

You just invoke sendmail with the -bt parameter. As an example:

/usr/lib/sendmail -bt -Ciu-testconfiguration.cf

Please be aware that in this method, Sendmail requires an special configuration on rewrite rules. You need to understand how Sendmail rewrites addresses in order to properly create a .cf file for Test Mode.


Edit: See this article: http://ussg.iu.edu/usail/mail/debugging/

vmarquez
+4  A: 

While searching for options I found the following that may be useful.

Zoredache
+3  A: 

For .NET I set the config file to deliver mail to a folder, then you can have the automated test inspect the directory and files.

<system.net>
 <mailSettings>
  <smtp deliveryMethod="SpecifiedPickupDirectory">
   <specifiedPickupDirectory pickupDirectoryLocation="c:\pickupDirectory"/>
  </smtp>
 </mailSettings>
</system.net>
George
+1  A: 

Exim can be configured to accept incoming mails but not deliver them. Look for the keywords queue_only and queue_only_file in the documentation.

hillu
+2  A: 

"The Wiser framework for unit testing mail"

I've heard of a few other developers moving from Dumbster to Wiser and have migrated my testing code as well. One of the Java components that I've worked on sends thousands of emails a day and I've written unit tests for the different email templates and scenarios using Dumbster and Wiser. I prefer Wiser.

Snips from the Wiser website (http://code.google.com/p/subethasmtp/wiki/Wiser):

Wiser is a smart replacement for Dumbster and is built on top of the SubEtha SMTP Java library which allows your Java application to receive SMTP mail with a simple, easy-to-understand API.

JT
A: 

A good program for email testing is smtp4dev (Windows only).

It's a 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.

http://smtp4dev.codeplex.com/

Soundlink