Convert Figma logo to code with AI

mailhog logoMailHog

Web and API based SMTP testing

15,110
1,120
15,110
250

Top Related Projects

Catches mail and serves it through a dream.

Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

7,456

An email and SMTP testing tool with API for developers

smtp4dev - the fake smtp email server for development and testing

Dummy SMTP server with GUI for testing emails in applications easily.

Quick Overview

MailHog is an email testing tool for developers. It provides a fake SMTP server that captures outgoing emails from your application, allowing you to view and test them without actually sending them to real recipients. MailHog offers a web interface for easy management and inspection of captured emails.

Pros

  • Easy to set up and use, with minimal configuration required
  • Cross-platform compatibility (Windows, macOS, Linux)
  • Provides both web and API interfaces for email management
  • Supports SMTP and HTTP protocols for sending mail

Cons

  • Limited email rendering capabilities compared to real email clients
  • May not fully simulate all email delivery scenarios
  • No built-in load testing or high-volume email handling features
  • Lacks advanced features like email authentication testing (SPF, DKIM, DMARC)

Getting Started

  1. Install MailHog:

    # Using Go
    go install github.com/mailhog/MailHog@latest
    
    # Or download a pre-built binary from GitHub releases
    
  2. Run MailHog:

    MailHog
    
  3. Configure your application to use MailHog as the SMTP server:

    SMTP_HOST=localhost
    SMTP_PORT=1025
    
  4. Access the web interface at http://localhost:8025 to view captured emails.

Competitor Comparisons

Catches mail and serves it through a dream.

Pros of MailCatcher

  • Written in Ruby, making it easier to integrate with Ruby-based projects
  • Simpler setup process, especially for Ruby developers
  • Lightweight and consumes fewer system resources

Cons of MailCatcher

  • Less actively maintained compared to MailHog
  • Fewer features and customization options
  • Limited support for non-Ruby environments

Code Comparison

MailCatcher (Ruby):

require 'mail_catcher'

MailCatcher.start(
  smtp_ip: '0.0.0.0',
  smtp_port: 1025,
  http_ip: '0.0.0.0',
  http_port: 1080
)

MailHog (Go):

import "github.com/mailhog/MailHog/config"

cfg := &config.Config{
    SMTPBindAddr: "0.0.0.0:1025",
    APIBindAddr:  "0.0.0.0:8025",
    UIBindAddr:   "0.0.0.0:8025",
}

Both MailCatcher and MailHog serve as SMTP testing tools, but MailHog offers more features, better cross-platform support, and is more actively maintained. MailCatcher may be preferred in Ruby-centric environments due to its simplicity and easy integration. However, for more comprehensive email testing and broader language support, MailHog is generally the recommended choice.

Disposable webmail server (similar to Mailinator) with built in SMTP, POP3, RESTful servers; no DB required.

Pros of Inbucket

  • Supports multiple storage backends (memory, filesystem, SQLite)
  • Provides a REST API for programmatic access to messages
  • Offers a web-based user interface for easy message viewing and management

Cons of Inbucket

  • Less actively maintained compared to MailHog
  • Fewer configuration options and customization features
  • Limited cross-platform support (primarily focused on Linux and macOS)

Code Comparison

MailHog (Go):

func CreateMessage(message *data.SMTPMessage) ([]byte, error) {
    msg := gomail.NewMessage()
    msg.SetHeader("From", message.From)
    msg.SetHeader("To", message.To...)
    msg.SetHeader("Subject", message.Subject)
    msg.SetBody("text/plain", message.Data)
    return msg.Bytes()
}

Inbucket (Go):

func (m *Message) AsEmail() (*email.Email, error) {
    e := &email.Email{}
    e.From = m.From
    e.To = m.To
    e.Subject = m.Subject
    e.Text = []byte(m.Text)
    e.HTML = []byte(m.HTML)
    return e, nil
}

Both projects are written in Go and provide similar functionality for handling email messages. MailHog offers a more feature-rich and actively maintained solution, while Inbucket provides flexibility in storage options and a REST API. The choice between the two depends on specific project requirements and desired features.

7,456

An email and SMTP testing tool with API for developers

Pros of Mailpit

  • Actively maintained with regular updates
  • Supports SMTP authentication
  • Offers a more modern and responsive web UI

Cons of Mailpit

  • Fewer configuration options compared to MailHog
  • Less established community and ecosystem

Code Comparison

MailHog configuration example:

cfg := &config.Config{
    SMTPBindAddr: "0.0.0.0:1025",
    APIBindAddr:  "0.0.0.0:8025",
    Hostname:     "mailhog.example",
}

Mailpit configuration example:

config := &Config{
    SMTPListen:   "0.0.0.0:1025",
    HTTPListen:   "0.0.0.0:8025",
    WebUIPath:    "/",
    AuthFile:     "auth.json",
}

Both projects serve similar purposes as email testing tools, but Mailpit offers some modern improvements and active development. MailHog has a larger user base and more extensive documentation. The code examples show similar configuration approaches, with Mailpit including additional options like authentication file support.

smtp4dev - the fake smtp email server for development and testing

Pros of smtp4dev

  • Built with .NET Core, offering cross-platform compatibility and better performance
  • Supports IMAP protocol in addition to SMTP, allowing for more comprehensive email testing
  • Provides a more modern and feature-rich web interface with real-time updates

Cons of smtp4dev

  • Requires .NET Core runtime, which may not be available on all systems
  • Has a more complex setup process compared to MailHog's single binary deployment
  • Less widespread adoption and community support than MailHog

Code Comparison

MailHog (Go):

func CreateSMTPListener(cfg *config.Config) (net.Listener, error) {
    addr, err := net.ResolveTCPAddr("tcp4", cfg.SMTPBindAddr)
    if err != nil {
        return nil, err
    }
    return net.ListenTCP("tcp4", addr)
}

smtp4dev (C#):

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<ISmtpServer>(sp => 
        new SmtpServer.SmtpServer(new SmtpServerOptionsBuilder()
            .ServerName("smtp4dev")
            .Port(25)
            .Build()));
}

Both projects aim to provide local SMTP testing environments, but smtp4dev offers more features and protocols at the cost of a slightly more complex setup. MailHog remains popular due to its simplicity and ease of use across various platforms.

Dummy SMTP server with GUI for testing emails in applications easily.

Pros of FakeSMTP

  • Lightweight and easy to set up, requiring minimal configuration
  • Written in Java, making it platform-independent and easily integrated into Java-based projects
  • Provides a simple GUI for viewing received emails

Cons of FakeSMTP

  • Limited features compared to MailHog, lacking advanced filtering and API capabilities
  • Less active development and community support
  • No built-in web interface for remote access to captured emails

Code Comparison

MailHog (Go):

func CreateSMTP(cfg *config.Config, storage storage.Storage) *SMTPServer {
    return &SMTPServer{
        config:  cfg,
        storage: storage,
    }
}

FakeSMTP (Java):

public class SMTPServer {
    private ServerSocket serverSocket;
    private boolean stopped = false;

    public void start(int port) throws IOException {
        serverSocket = new ServerSocket(port);
    }
}

Both projects aim to provide fake SMTP servers for testing purposes, but MailHog offers a more feature-rich solution with a web interface and API support. FakeSMTP, on the other hand, provides a simpler, Java-based alternative that may be preferable for Java developers or those seeking a lightweight solution. MailHog's codebase is in Go, while FakeSMTP is written in Java, which may influence the choice depending on the development environment and integration requirements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

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

MailHog is an email testing tool for developers:

  • Configure your application to use MailHog for SMTP delivery
  • View messages in the web UI, or retrieve them with the JSON API
  • Optionally release messages to real SMTP servers for delivery

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:

  • the SMTP server starts on port 1025
  • the HTTP server starts on port 8025
  • in-memory message storage

Features

See MailHog libraries for a list of MailHog client libraries.

  • ESMTP server implementing RFC5321
  • Support for SMTP AUTH (RFC4954) and PIPELINING (RFC2920)
  • Web interface to view messages (plain text, HTML or source)
    • Supports RFC2047 encoded headers
  • Real-time updates using EventSource
  • Release messages to real SMTP servers
  • Chaos Monkey for failure testing
  • HTTP API to list, retrieve and delete messages
    • See APIv1 and APIv2 documentation for more information
  • HTTP basic authentication for MailHog UI and API
  • Multipart MIME support
  • Download individual MIME parts
  • In-memory message storage
  • MongoDB and file based storage for message persistence
  • Lightweight and portable
  • No installation required

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.