MailHog README

The project's README from github.com/mailhog/MailHog. As one markdown file: README.md.

MailHog Download GoDoc Build Status

Inspired by MailCatcher, easier to install.

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

Overview

MailHog is an email testing tool for developers:

Installation

Manual installation

Download the latest release for your platform. Then read the deployment guide for deployment options.

MacOS

brew update && brew install mailhog

Then, start MailHog by running mailhog in the command line.

Debian / Ubuntu Go < v1.18

sudo apt-get -y install golang-go
go get github.com/mailhog/MailHog

Go >= v1.17 (Debian Bookworm)

sudo apt-get -y install golang-go
go install github.com/mailhog/MailHog@latest

Then, start MailHog by running /path/to/MailHog in the command line.

E.g. the path to Go's bin files on Ubuntu is ~/go/bin/, so to start the MailHog run:

~/go/bin/MailHog

FreeBSD

pkg install mailhog
sysrc mailhog_enable="YES"
service mailhog start

Docker

Run it from Docker Hub or using the provided Dockerfile

Configuration

Check out how to configure MailHog, or use the default settings:

Features

See MailHog libraries for a list of MailHog client libraries.

sendmail

mhsendmail is a sendmail replacement for MailHog.

It redirects mail to MailHog using SMTP.

You can also use MailHog sendmail ... instead of the separate mhsendmail binary.

Alternatively, you can use your native sendmail command by providing -S, for example:

/usr/sbin/sendmail -S mail:1025

For example, in PHP you could add either of these lines to php.ini:

sendmail_path = /usr/local/bin/mhsendmail
sendmail_path = /usr/sbin/sendmail -S mail:1025

Web UI

Screenshot of MailHog web interface

Contributing

MailHog is a rewritten version of MailHog, which was born out of M3MTA.

Clone this repository to $GOPATH/src/github.com/mailhog/MailHog and type make deps.

See the Building MailHog guide.

Requires Go 1.4+ to build.

Run tests using make test or goconvey.

If you make any changes, run go fmt ./... before submitting a pull request.

Licence

Copyright ©‎ 2014 - 2017, Ian Kent (http://iankent.uk)

Released under MIT license, see LICENSE for details.

MailHog (mailhog/MailHog)

smtp
Searching Database…

16.2K ·GitHub
What is this?MailHog is an email testing tool for developers. You point your application's outgoing SMTP at it, then view the captured mail in a web UI or fetch it through a JSON API, instead of delivering it for real.
Is this a library I add to my code, or a service I run separately?It runs separately: a single Go binary that acts as a fake SMTP server with a built-in web UI and HTTP API. Your app never embeds MailHog — it just sends mail to it like any SMTP server.
How do I get it running?Download the latest release for your platform and run the binary, or run the Docker image from Docker Hub. With default settings the SMTP server listens on port 1025 and the web UI on port 8025.
Do I need to install anything like Go first?No — it is built with Go and runs without installation on multiple platforms. You only need a Go toolchain (1.4+) if you build it from source yourself.
Do the test emails survive a restart?By default messages are kept in memory, so they disappear when MailHog stops. For persistence you can switch to MongoDB or file-based storage.
Will any of my test emails reach real recipients?No — captured messages stay inside MailHog until you explicitly release them to a real SMTP server for delivery.
Is it free to use?Yes — MailHog is released under the MIT license, so it is free to use, modify and redistribute.
How do I point my application at MailHog?Set your app's outgoing SMTP server to MailHog's port 1025. There is also mhsendmail, a sendmail replacement that redirects mail to MailHog via SMTP — for example, a PHP app can point sendmail_path at it in php.ini.
What happens to a message once MailHog catches it?It appears in the web UI in real time (updates via EventSource), where you can read it as plain text, HTML or raw source and download individual MIME parts. You can also list, retrieve and delete messages through the HTTP API (v1 and v2), protected by optional basic auth.
Can MailHog simulate delivery failures?Yes — it ships with Jim, a Chaos Monkey feature for failure testing, so you can check how your app copes when SMTP delivery misbehaves.
How is MailHog different from MailCatcher?It was inspired by MailCatcher but is easier to install: being written in Go, it ships as a lightweight binary that runs without installation on multiple platforms, with a Docker image available.
Creator
mailhog
Size
2.9 MB
Stars
16.2K
Age
12y
Commits · 90 Days