DEV Community

Stephane Paquet
Stephane Paquet

Posted on

Mailcatcher for beginners

When in need to troubleshoot email messages use Mailcatcher.

Mailcatcher is a simple SMTP server that you can run locally or remotely intercept emails during test and development phases.

Once captured by Mailcatcher emails can be rendered from within their web interface and exported to be opened in any mail client.

Mailcatcher web interface is refreshed in realtime when your app is using websocket otherwise every 30 seconds.

Mailcatcher is language agnostic and simple to use as you just have to redirect SMTP traffic to Mailcatcher smtp port 1025.

So, let's say that you have an application that uses an external SMTP provider and that you have Mailcatcher running locally, you just need to replace your third party provider by smtp://127.0.0.1:1025 and done!

To access Mailcatcher web interface, simply point to http://127.0.0.1:1080.

If for any reason your instance of Mailcatcher is using a different IP address, just adapt the above examples.

Over the years, I found it more convenient to not install Mailcatcher on my computer, but have it running in a docker image.

Here are few ways to have it up and running:

  • docker run --rm -p 1080:1080 -p 1025:1025 --name mailcatcher stpaquet/alpinemailcatcher Will delete the image once you are done using it. This could be interesting for a test environment.
  • docker run -d -p 1080:1080 -p 1025:1025 --name mailcatcher stpaquet/alpinemailcatcher Will launch the image as a daemon.
  • docker run -it -p 1080:1080 -p 1025:1025 --name mailcatcher stpaquet/alpinemailcatcher Will launch the image in interactive mode

Useful links:
Mailcatcher homepage: mailcatcher.me
Dockerfile and Docker Compose: https://github.com/spaquet/docker-alpine-mailcatcher
Dockerhub: https://hub.docker.com/r/stpaquet/alpinemailcatcher

Longer article can be found on Medium with Docker Compose basic configuration and more examples: https://medium.com/@spaquet/mailcatcher-to-the-rescue-4ba438dc98c2

Top comments (0)