Self-hosted inbound email processing: SMTP or Maildir in, signed JSON webhooks out.
Warning
🚧 Do Not Use — History Will Be Rewritten 🚧
MXHook accepts SMTP or Maildir messages, persists the raw message, parses and routes it, then delivers a signed JSON webhook with durable retries.
SQLite is the default and needs no external service. Postgres is optional for multi-process deployments. The hosted Cloudflare implementation is a separate, experimental target.
MXHook receives mail and never sends it. It accepts SMTP, forwards over HTTPS, and never connects out to another mail server, generates bounces, or relays. No SPF or DKIM record is required for MXHook, and adding an MX record leaves a domain's existing outbound records untouched. See Pointing a domain at MXHook.
Linux and macOS. Windows is unsupported (Maildir ingestion is POSIX-only).
go install github.com/mxhook/mxhook@latestClone the repository for the Compose files, then fill in the environment template:
git clone https://github.com/MXHook/MXHook.git mxhook
cd mxhook
cp .env.example .env
# Set every blank value in .env, including the webhook destination and secrets.docker compose up -d --build
docker compose ps
curl -fsS http://127.0.0.1:8080/readyzThe base Compose file exposes only the control API on localhost. Add one ingress overlay:
# Public SMTP with mandatory STARTTLS
docker compose -f docker-compose.yml -f docker-compose.smtp-tls.yml up -d --build
# Exclusive Maildir ingestion
MAILDIR_PATH="$HOME/Maildir" \
docker compose -f docker-compose.yml -f docker-compose.maildir.yml up -d --buildThe SMTP overlay requires certificate and key paths configured in .env.
Production MX traffic normally uses host port 25; verify that the host and
provider allow inbound TCP/25 before changing DNS. MXHook listens on :2525
inside the container so it can run unprivileged, and the overlay publishes host
port 25 to it. See Pointing a domain at MXHook for the DNS
records, provider port-25 policies, and a cutover checklist.
Postgres must be selected explicitly:
MXHOOK_QUEUE_BACKEND=postgres \
MXHOOK_DATABASE_URL='postgres://mxhook:secret@postgres:5432/mxhook?sslmode=disable' \
POSTGRES_PASSWORD=secret \
docker compose --profile postgres up -d --buildexport MXHOOK_STATE_ENCRYPTION_KEY="$(openssl rand -base64 32)"
export MXHOOK_API_KEY="$(openssl rand -hex 32)"
export MXHOOK_WEBHOOK_URL=https://receiver.example.com/inbound-email
export MXHOOK_WEBHOOK_SECRET="$(openssl rand -hex 32)"
mxhook start --smtp-addr :2525 --recipient-domain example.comThe static catch-all route can later be replaced or overridden by API routes.
For a two-stage deployment, first start the worker role with ingress disabled,
create a route through the authenticated API, then restart with role all.
all refuses to open ingress while the durable route set is empty.
mxhook config validate checks effective configuration without opening a
listener. Flags override environment variables, which override YAML values;
defaults apply last.
- SMTP and Maildir ingress; MXHook receives mail and never sends it.
- Durable pipeline: the raw message is persisted, parsed, routed, then delivered.
- SQLite by default; Postgres for multi-process deployments.
- Signed JSON webhooks with durable retries, dead-letter inspection, and replay.
- REST API and CLI for domains, routes, messages, and replays.
Webhook receivers must deduplicate on X-MXHook-Delivery-ID. Delivery is
at-least-once, so a response can be repeated after a timeout or crash even when
the receiver handled the first request.
Deliveries are signed Stripe-style: X-MXHook-Signature is the HMAC-SHA256 of
"{unix_ts}.{payload}" and X-MXHook-Timestamp carries the signed timestamp.
Verify with webhook.VerifyTimestampedSignature, which rejects timestamps
outside a tolerance window (default five minutes) so captured requests cannot
be replayed. Upgrade receivers to the timestamped verification before
upgrading the sender; the legacy payload-only scheme remains verifiable via
the explicit webhook.VerifySignature path for senders that predate
timestamped signing.
- SMTP refuses startup without at least one accepted recipient domain.
- Public SMTP can require STARTTLS; the production overlay enables it.
- Webhook destinations require HTTPS and public IP addresses. DNS is checked again at connection time and after redirects.
- Every configured webhook requires an HMAC secret; route secrets are encrypted at rest.
- The container runs as numeric non-root, uses a read-only root filesystem, and
writes only to
/dataand declared Maildir/TLS mounts. - Raw email and SQLite files use owner-only permissions.
- Pointing a domain at MXHook
- Configuration
- Operations and recovery
- Architecture
- CLI reference
- Maildir ingestion
- Durable queue contract
- Glossary
- OpenAPI specification
- I want to USE MXHook → SKILL.md
- I want to MODIFY MXHook → DEVELOPING.md
Changes follow CONTRIBUTING.md and the Code of Conduct.
GNU Affero General Public License v3.0 only (AGPL-3.0-only) — see
LICENSE and NOTICE. The ee/ directory is licensed
separately under the Business Source License 1.1 — see ee/LICENSE.