Back to services

MailCatcher

Deploy a simply SMTP MTA gateway that accepts all mail and displays in web interface. Useful for debugging or development.

View alternatives to MailCatcher
Suggest edit
Recent reviews

Alternatives

Tech stack

No tech stack added yet. Sign in to suggest some

Introduction

MailCatcher is an open-source (MIT license) email capture tool for development, created by Samuel Cochran and distributed as a Ruby gem. The latest version listed on the official website is 0.10.0 (released in May 2024). It runs a very simple SMTP server locally, catches all the emails your application sends, and displays them through a browser interface. Developers can view and debug email content locally without worrying about test emails being sent to real users by mistake.

Key Features

  • Catches all emails: Receives every email sent to it and stores it for viewing.
  • Multiple views: Shows the HTML, plain text and raw source versions, depending on what the email actually contains.
  • HTML rewriting: Displays embedded images and other resources correctly, and links open in a new window.
  • Attachment handling: Lists attachments, and each part can be downloaded separately.
  • Raw email download: Lets you export the raw email and open it in a local email client.
  • Live updates: New emails appear instantly if the browser supports WebSockets; otherwise the page refreshes every 30 seconds.
  • Background operation: Runs as a daemon in the background by default, or can run in the foreground.
  • catchmail command: Provides a sendmail-like catchmail command, making it easy to integrate with PHP projects.
  • Keyboard navigation: Lets you move between emails with the keyboard.
  • REST-style API: Lets you retrieve the email list and email content over HTTP.

Target Users and Use Cases

It is suited to web developers who need to debug email sending in development or testing environments, such as developers working on Ruby on Rails, PHP (including Drupal and others) and Django projects. Common uses include checking how transactional emails such as sign-up confirmations, password resets and notifications render and what they contain.

Installation and Usage

  1. Install: gem install mailcatcher
  2. Start: mailcatcher
  3. Open http://127.0.0.1:1080/ in your browser to view the emails received
  4. Have your application send email via smtp://127.0.0.1:1025

Run mailcatcher --help to see the command-line options, for example to change the default SMTP/HTTP listening addresses and ports (--smtp-ip, --smtp-port, etc.).

Note: The official recommendation is not to add mailcatcher to your project's Gemfile, because sooner or later it will conflict with your application's own gems. A better approach is to explain how to install it in your README. If you use RVM, it is recommended to install it in a separate gemset and create a wrapper script.

Framework Configuration Examples

  • Rails: In environments/development.rb, set delivery_method to :smtp, the address to 127.0.0.1 and the port to 1025.
  • PHP: In php.ini, set sendmail_path = /usr/bin/env catchmail -f [email protected].
  • Django: In settings.py, in DEBUG mode, set EMAIL_HOST='127.0.0.1', EMAIL_PORT=1025 and EMAIL_USE_TLS=False.

API

  • /messages: Get the email list (JSON)
  • /messages/:id.json: Get the metadata of a single email
  • /messages/:id.html, /messages/:id.plain: Get the HTML or plain text content
  • /messages/:id/:cid: Get a single attachment by CID
  • /messages/:id.source: Get the complete raw email

Technical Requirements

  • Requires a Ruby environment; installed via RubyGems
  • Uses port 1025 (SMTP) and port 1080 (HTTP) by default

Notes

  • The email handling logic is fairly basic, but easy to modify.
  • It cannot fully support UTF-8 content transmitted as-is over SMTP; you need to use an email library that correctly encodes messages according to the SMTP server's capabilities.
  • For development and testing only; it is not a production mail server.