tags:

views:

679

answers:

5

Working on an app with notification via e-mail. I'd like to run test with out sending e-mails to production servers and clients. A couple years ago I remember someone bringing down our exchange server with a bad e-mail loop and would prefer to not repeat...

Any suggestion for a dev setup? Currently think a simple SMTP server will do the job but I'm not familiar with that space. I would need the ability to see all the emails sent to the server but they should never be delivered.

Thanks.

A: 

Why not simply spit the email list out to a text file and disconnect any calls to the mail Server?

madcolor
+1  A: 

Depending on what your email mechanism is, another alternative would be to make a testmail.(py,php,sh) script that records all arguments provided and dumps them into a tag table with event time stamps. It's not elegant, but would do for debugging. Trick all depends on how you send email.

Along the same lines, if you use smtp and not sendmail, is write a ghetto app that listens on some high range port number and just dumbly responds back with the correct values.

David
+5  A: 

It's pretty simple to set up an alias that is delivered to a file instead of through any delivery mechanism in any of the major Unix/Linux mail servers like Postfix or Sendmail. During the testing, you can tail that file to see that the mail is getting send when you expect it to. After your testing is over, you can re-direct it to where-ever it's really supposed to go.

Paul Tomblin
I'm going to looks at this to as part of the larger test/dev environment. Thanks!
jms
A: 

Your question didn't describe the environment, but if you are using an OO language (e.g. Java) you could use dependency injection. Write a MessageSender interface with two implementations; one (EmailMessageSender) actually sends emails, while the other (FileMessageSender) captures the message in a string.

Write and test EmailMessageSender in isolation; once it's verified, put it on the shelf.

Write the other parts of the system against MessageSender and test them using an (injected) instance of FileMessageSender. (If FileMessageSender also allows retrieval of the "sent message" content, then you can use it in unit testing.)

Once you've verified the rest of the system, deploy it using (again via injection) a properly-configured instance of EmailMessageSender.

joel.neely
+4  A: 

Papercut is the perfect fit for what you are looking for. It has been publicly available for the last couple of months. I have been using it for a month. It couldn't get any easier to test email functionality.

  1. Download Papercut.
  2. Run Papercut, while running it sits in your tray.
  3. Configure your application's smtp host to the machine running Papercut.
  4. Watch Papercut receive the emails and view the contents.
  5. When you are done. Close Papercut.
Dale Ragan