mail-tester/README.md
Jonas Leder 02884ed30d Run migrations in Helm post-install/upgrade hook Job (mysql/postgres)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 11:46:58 +01:00

2.1 KiB

Mail Tester

Open source alternative to mail-tester.com. Open the page, get a random address xxxxxxxxxx@your-domain, send a mail to it, get a score out of 10.

Checks: SpamAssassin, SPF, DKIM, DMARC, reverse DNS (FCrDNS), MX record, A/AAAA of MX hosts, 7 DNS blacklists, TLS in transit, message format (Message-ID, Date, MIME, text alternative). Weights live in backend/checks.go; skipped checks (e.g. no spamd) don't count.

SpamAssassin runs as a sidecar container next to the backend (the backend image is scratch).

Stack: Go (Gin, Gorm + gormigrate, swaggo, godotenv), React + Vite, Stalwart via JMAP.

Run

# edit the environment block in compose.yaml, then:
docker compose up --build   # frontend :8080, backend, spamassassin

Kubernetes: helm install mail-tester ./helm -f my-values.yaml (frontend and backend are separate deployments, SpamAssassin is a sidecar of the backend; backend scales with replicaCountBackend on mysql/postgres; sqlite is limited to 1).

Migrations run at backend startup; EXECUTE_MIGRATIONS=false disables that and mailtester migrate applies them once and exits (the Helm chart does this in a post-install/post-upgrade hook Job for mysql/postgres).

Database: DB_DRIVER=sqlite|mysql|postgres with DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME (DB_SSLMODE for postgres; for sqlite DB_NAME is the file path). See .env.example.

Then set up Stalwart: docs/stalwart.md.

Dev: cd backend && go run . (reads .env) and cd frontend && npm i && npm run dev (proxies /api to :8080).

API

curl -X POST https://host/api/v1/tests          # -> {"id","address",...}
curl https://host/api/v1/tests/<id>             # status waiting|done|expired, score, checks[]

OpenAPI / Swagger UI at /api/docs/index.html. Regenerate with cd backend && swag init -g main.go -o docs.

Security

Strict CSP, HSTS, COOP/COEP/CORP, X-Frame-Options, Permissions-Policy etc. on every response (Swagger UI path gets a relaxed script/style CSP). Create endpoint is rate limited per IP; set TRUSTED_PROXIES behind a reverse proxy.