This article targets development and QA environments. It shows how to run MailHog with Docker Compose and use it together with this temp inbox project to validate verification-code emails and notifications.
MailHog is an email testing tool. It provides an SMTP server to accept messages and a Web UI / HTTP API to inspect them.
If you use the repository docker-compose.yml, it typically already includes Redis, MailHog, and the app. Here is a minimal example for clarity:
services:
mailhog:
image: mailhog/mailhog:latest
ports:
- "25:1025"
- "127.0.0.1:8025:8025"
redis:
image: redis:7-alpine
app:
image: node:20-alpine
working_dir: /app
environment:
- MAILHOG_API=http://mailhog:8025
- REDIS_URL=redis://redis:6379
volumes:
- ./app:/app
command: node server.jsStart:
docker compose up -dhttp://127.0.0.1:8025http://mailhog:8025/api/v2/messageshttp://127.0.0.1:3000127.0.0.1 (local) or mailhog (docker network)1025MAILHOG_API.MailHog is intended for testing. For production, use a real email service (SES/SendGrid/Mailgun, etc.).