Every now and then, you come across developing an application, that sends email. How to simple test this application? It’s easy, if you have an own mail server. For Windows, there is the very simple smtp4dev application, that listens on localhost port 25 and displays all emails that would have been transmitted. A similar but cross-platform tool is FakeSMTP. For a server, fakemail might be worth a look at.

However, all these solutions only work, if your application uses TCP to send a mail, but what about sendmail. This is a typical solution for PHP applications - they just handover the mail to sendmail and let sendmail deliver it.

Luckily, there is an easy solution - at least, if you are running Debian and exim4: As described in Basic Exim configuration to redirect all outbound emails you’ll need to do the following:

  1. Create a file /etc/exim4/conf.d/router/01_catch-all-outgoing with the following content:

      debug_print = "R: to andreas"
      driver = redirect
      data = andreas

    Of course - replace “andreas” with your local user account.

  2. Make sure, to have set dc_use_split_config='true' in file /etc/exim4/update-exim4.conf.conf. This configures Debian to generate the final exim configuration based on the files in /etc/exim4/conf.d.

  3. Regenerate the final exim configuration with sudo update-exim4.conf and restart exim with sudo service exim4 restart.

  4. Configure Thunderbird and add a local mail account: Menu “Edit”, “Account Settings”, “Account Actions”, “Add Other Account” and select “Unix Mailspool (Movemail)” and follow the wizard.

You can test your setup, by sending a mail on the command line, e.g.

cat <<EOF | sudo sendmail recipient@example.com
From: test@example.com
To: recipient@example.com
Subject: test mail from command line

Hello World!

You email should be arriving now in Thunderbird.