I need to set up a SMTP server in a dev environment that will accept all mail sent to it (for any domain) and simply store it so we can later see what it has caught. What is the easiest way to set this up? (Can be any OS/setup, since we'll likely do this as a new VM)

For bonus points, can it catch and store all mail except for mail to @mydomain.com, which it should send as normal?


You can pull this off with Exim. The advantage oiver something like Devnull is that it will run as a background process "out of the box", and definitely can handle delivering the "@mydomain.com" email via normal means. It's a plain ol' SMTP server that has a very flexible configuration.

We use Exim to archive email (in BSMTP format) inbound and outbound for our domain. The basic "recipe" we're using is a "router" to catch incoming mail and another to catch outgoing mail. Each router invokes a transport that saves to a datestamped file (/var/log/exim/archive-${substr{0}{8}{$tod_zulu}}). The last line of the router includes an "unseen" to cause the message to traverse the rest of the routers in the configuration file (to perform "normal delivery"). You might not need that "unseen" functionality.

I think the documentation for Exim is top-notch, and it's pretty easy to configure, once you get your mind wrapped around the metaphor.

| improve this answer | |

Devnull SMTP server will save email to files. It's pure java so there's no dependencies outside the JVM.

| improve this answer | |
  • I've used Devnull for development before, and it will definitely work for you. The only downside is that you have to start it before use; it doesn't seem to run as a service. – Paul Kroon Jul 20 '10 at 11:00
  • 1
    Yeah... You start it and need to click a button on the GUI to get it to start listening. Wish it would run without intervention. Devnull SMTP developers, are you listening? – Chris Nava Jul 20 '10 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.