MailCatcher in Docker

How to set up a fake SMTP server in a container for receiving and viewing emails

Courtney Zhan
3 min readSep 11, 2022

--

In previous articles, we discussed email testing and using a fake SMTP server to catch emails. This article will show you how to set up a Docker container to host MailCatcher, a simple fake SMTP server.

Why is Docker a good set-up option for MailCatcher?

  • Independent
    MailCatcher is an isolated and independent component with no dependencies. It makes sense to stand up an individual container to handle this.
  • Reusable
    MailCatcher can be used to service any number of applications.
    Depending on your use case, you may want to set up multiple containers (with different ports) to separate the apps. It is easy to duplicate an existing Docker image into a new container.

So, if you already using Docker, then MailCatcher-in-Docker is a quick and easy setup.

Setting up MailCatcher

The general steps to set up and run MailCatcher:

  1. Install Ruby
  2. Install the gem mailcatcher

--

--