selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
MailHog logo

Self-host MailHog

v1.0.1

Email capture and testing server for developers

ReleaseOpen SourceMIT
Updated2 years ago
LanguageGo
Setup difficultyEasy
Stars
16 207
Ports
1025 (SMTP server that receives the test mail your application sends), 8025 (HTTP server for the web UI and the JSON API)
Docker
mailhog/mailhog
Install with Docker
MailHog web interface showing captured messages

What is MailHog?

MailHog is a small SMTP server that developers run locally to catch the mail their application sends instead of delivering it to a real inbox. Captured messages are browsable in a web UI where they can be read as plain text, HTML or raw source, with live updates pushed to the browser and individual MIME parts downloadable; a JSON HTTP API exposes the same messages for listing, retrieving, downloading and deleting. Mail can be released onward to a real SMTP server, chosen in the UI or defined permanently in a JSON file of outgoing servers. For failure testing, the built-in Chaos Monkey called Jim randomly disconnects sessions, rate-limits links or rejects senders, recipients and authentication, each with its own tunable probability. Storage defaults to memory, with a Maildir directory or MongoDB available when messages must persist, and the UI and API can be locked behind HTTP basic auth using a bcrypt password file. Written in Go, it needs no installation: run a downloaded binary, a Homebrew or FreeBSD package, or the mailhog/mailhog container image exposing 1025 and 8025. It is a mail-testing tool rather than a production mail server, and no release has shipped since v1.0.1 in 2020.

MailHog alternatives

All self-hosted alternatives to MailCatcher →

Should you self-host MailHog?

MailHog scores 67/100 on selfhost.directory (how scoring works) and ranks #10 of 109 in Email. It has 16 207 GitHub stars, +25 in the last 30 days.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in Go.

Its closest alternative on selfhost.directory is Listmonk (80/100, 24 290 stars). It scores higher overall, so compare the two before you pick. See MailHog vs Listmonk side by side.

Features

  • Chaos testing
  • CORS for API endpoints
  • Customisable bind addresses and web path
  • HTTP Basic Authentication
  • Message persistence backends
  • MIME part downloads
  • MIME Support
  • Outgoing mail release
  • Real-time updates
  • REST API
  • Sendmail replacement mode
  • SMTP AUTH and PIPELINING
  • SMTP capture server
  • Web UI message viewer

MailHog README

MailHog Download GoDoc Build Status

Inspired by MailCatcher, easier to install.

  • Download and run MailHog
  • Configure your outgoing SMTP server
  • View your outgoing email in a web UI
  • Release it to a real mail server

Built with Go - MailHog runs without installation on multiple platforms.

Overview

How to install MailHog

Install MailHog with Docker

Environment variables
MH_STORAGE

docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog

To keep messages on disk, mount a Maildir volume: docker run -d -e "MH_STORAGE=maildir" -v $PWD/maildir:/maildir -p 1025:1025 -p 8025:8025 mailhog/mailhog

How to configure MailHog

  • MH_AUTH_FILEA username:bcryptpw mapping file
  • MH_UI_WEB_PATHWebPath under which the UI is served (without leading or trailing slashes), e.g. 'mailhog'
  • MH_STORAGEmemorySet message storage: memory / mongodb / maildir
  • MH_MONGO_URI127.0.0.1:27017MongoDB host and port
  • MH_MONGO_COLLECTIONmessagesMongoDB collection name for message storage

MailHog releases & version history

@ Every self-hosted release, weekly

One Monday email with the week's stable releases across the directory.

More in Email

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…