Configuration
MXHook is configured via environment variables or CLI flags. CLI flags take precedence over environment variables.
Environment Variables
| Variable | CLI Flag | Default | Description |
|---|---|---|---|
MXHOOK_SMTP_ADDR | --smtp-addr | 0.0.0.0:2525 | SMTP server listen address |
MXHOOK_SMTP_DOMAIN | --smtp-domain | localhost | SMTP server hostname (used in HELO/EHLO) |
MXHOOK_API_ADDR | --api-addr | 0.0.0.0:8080 | REST API listen address |
MXHOOK_POSTGRES_DSN | --db-url | — | PostgreSQL connection string (required) |
MXHOOK_API_KEY | --api-key | — | API authentication key. If empty, API is unauthenticated |
CF_QUEUE_ACCOUNT_ID | — | — | Cloudflare account ID (for Cloudflare Queue backend) |
CF_QUEUE_ID | — | — | Cloudflare queue ID |
CF_QUEUE_TOKEN | — | — | Cloudflare API token |
Example .env File
bash
# SMTP
MXHOOK_SMTP_ADDR=0.0.0.0:25
MXHOOK_SMTP_DOMAIN=mail.yourdomain.com
# API
MXHOOK_API_ADDR=0.0.0.0:8080
MXHOOK_API_KEY=your-secret-api-key
# Database
MXHOOK_POSTGRES_DSN=postgres://mxhook:mxhook@localhost:5432/mxhook?sslmode=requireSMTP Limits
| Limit | Default | Description |
|---|---|---|
| Max message size | 10 MB | Maximum size of a single email message |
| Max recipients | 50 | Maximum number of recipients per message |
| Rate limit | 100 msgs/hour per IP | Inbound rate limiting |
PostgreSQL
MXHook requires PostgreSQL 14 or later. The connection string follows the standard libpq format:
postgres://user:password@host:port/database?sslmode=disableMXHook automatically creates the required tables on first startup. No manual migration is needed.
Queue Backend
By default, MXHook uses PostgreSQL as its message queue (recommended for most deployments). For edge/serverless deployments, you can use Cloudflare Queues by setting the CF_QUEUE_* variables.