Docker
The recommended way to run MXHook in production.
Docker Compose
Create a docker-compose.yml:
yaml
services:
mxhook:
image: ghcr.io/mxhook/mxhook:latest
ports:
- "25:25" # SMTP
- "8080:8080" # API
environment:
MXHOOK_SMTP_ADDR: "0.0.0.0:25"
MXHOOK_SMTP_DOMAIN: "mail.yourdomain.com"
MXHOOK_API_ADDR: "0.0.0.0:8080"
MXHOOK_POSTGRES_DSN: "postgres://mxhook:mxhook@postgres:5432/mxhook?sslmode=disable"
depends_on:
- postgres
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: mxhook
POSTGRES_PASSWORD: mxhook
POSTGRES_DB: mxhook
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:Start the stack:
bash
docker compose up -dStandalone Docker
bash
docker run -d \
--name mxhook \
-p 25:25 \
-p 8080:8080 \
-e MXHOOK_SMTP_ADDR=0.0.0.0:25 \
-e MXHOOK_SMTP_DOMAIN=mail.yourdomain.com \
-e MXHOOK_POSTGRES_DSN=postgres://user:pass@host:5432/mxhook?sslmode=disable \
ghcr.io/mxhook/mxhook:latestHealth Check
Verify MXHook is running:
bash
curl http://localhost:8080/healthjson
{"status": "ok"}Production Considerations
- Port 25: Most cloud providers block outbound port 25 by default. For inbound SMTP, ensure your firewall allows TCP port 25 from the internet.
- TLS: Configure a reverse proxy (nginx, Caddy) for HTTPS on the API. SMTP STARTTLS support is built-in.
- Persistence: Always mount a volume for PostgreSQL data.
- Resources: MXHook is lightweight — 128MB RAM and 0.5 vCPU is sufficient for moderate traffic.