MailHog: Local SMTP server to testing emails locally

Michael Roma

MailHog is a fake SMTP server. It catches every email your app tries to send instead of actually delivering it, and shows them in a web UI so you can inspect them.

Run it with Docker:

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

Port 1025 is the SMTP server. Point your app’s mail settings at it:

SMTP_HOST=localhost
SMTP_PORT=1025

Port 8025 is the web UI. Open it here:

http://localhost:8025

Every email your app sends now shows up there instead of hitting a real inbox - subject, body, headers, attachments, all viewable.

MailHog also exposes an API for pulling messages programmatically, useful for asserting an email was sent in a test suite:

curl http://localhost:8025/api/v2/messages

To clear all captured messages:

curl -X DELETE http://localhost:8025/api/v1/messages

That’s it - no real SMTP provider, no risk of emailing real users during dev or CI.