How to setup a fake SMTP server to catch all mails?

Solution 1:

If you have python lying around this will write the SMTP conversation to stdout.

sudo python -m smtpd -n -c DebuggingServer localhost:25

http://docs.python.org/library/smtpd.html#debuggingserver-objects

Solution 2:

You should have a look at smtp-sink which is a part of Postfix. You don't have to run Postfix to make it work. Just install it to have the executable. Everything you need can be configured via command line parameters:

http://www.postfix.org/smtp-sink.1.html

Solution 3:

There is also a ruby gem called mailcatcher.

You can read the emails directly in your browser through the integrated web interface, there's a screenshot from their homepage below.

Mailcatcher interface

Solution 4:

We use http://mailtrap.io web service in developement and staging environment. It is platform-independent and doesn't require you to run your own SMTP.

It offers:

  • All emails in one place
  • Shared access for dev team to the inbox
  • Developer tools to analyze emails
  • Flexible configuration