Zoredache
Zoredache

Reputation: 39593

Method for email testing

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?

Upvotes: 28

Views: 11522

Answers (14)

AgilePro
AgilePro

Reputation: 5598

It is fairly easy to write a Java/JSP application that acts like an SMTP server, and will receive the emails from your application, and store them in a list with a user interface that allows you to inspect the emails.

I originally had a link to an open source package that did all this and would be a useful testing tool, but that was considered self promotion, and so the link has been removed. If you look around you should be able to find something like what I am describing.

Upvotes: 0

Tony Ly
Tony Ly

Reputation: 349

If you're looking to manually test that the email sends and that the email template has the right kind of html and css that you're expecting, then I would recommend maildev https://www.npmjs.com/package/maildev. You can install and run it as a node module and also as a docker container! I've found it extremely handy for basic sanity testing of emails.

Upvotes: 0

Frederic Morin
Frederic Morin

Reputation: 8943

In java you can use dumbster

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.

Upvotes: 15

yankee
yankee

Reputation: 40810

After not beeing happy with the solutions I found, I ended up writing developmentSMTP, easy to use, 100% Java --> cross platform.

Supports writing emails to file, forwarding emails or simply printing them on stdout.

Upvotes: 0

Soundlink
Soundlink

Reputation: 3931

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/

Upvotes: 5

JT.
JT.

Reputation: 53

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

Upvotes: 5

hillu
hillu

Reputation: 9611

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.

Upvotes: 1

George
George

Reputation: 7944

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>

Upvotes: 9

Zoredache
Zoredache

Reputation: 39593

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

Upvotes: 5

vmarquez
vmarquez

Reputation: 1377

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/

Upvotes: 0

Dan F
Dan F

Reputation: 12052

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.

Upvotes: 2

rmeador
rmeador

Reputation: 25704

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.

Upvotes: 0

dove
dove

Reputation: 20674

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

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

Upvotes: 2

Mitchel Sellers
Mitchel Sellers

Reputation: 63126

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.

Upvotes: 0

Related Questions