Self-host Mailprex with Docker
Run Mailprex on your own VPS with MongoDB and your SMTP server.
Quick start
- Copy environment file:
cp back/.example.env back/.env- Edit
back/.env— minimum required:
MAILPREX_MODE=selfhost
JWT_SECRET=your-long-random-secret
MAILPREX_SMTP_HOST=smtp.example.com
MAILPREX_SMTP_PORT=587
MAILPREX_SMTP_USER=your-user
MAILPREX_SMTP_PASS=your-password
FRONTEND_URL=http://localhost:3000- Start stack:
docker compose up -d --buildAPI listens on http://localhost:5000.
Environment reference
| Variable | Description |
|---|---|
MAILPREX_MODE | selfhost for private deployments |
MAILPREX_ALLOW_SIGNUP | false to disable public registration |
MAILPREX_REQUIRE_EMAIL_VERIFY | true to require email verification (default false in self-host) |
MAILPREX_SMTP_* | Custom SMTP transport (recommended) |
MONGODB_URI | Set automatically in docker-compose.yml to mongodb://mongo:27017/mailprex |
Frontend
Point the Next.js app to your API:
NEXT_PUBLIC_API_URL=http://localhost:5000For production, serve the front behind HTTPS on the same domain or configure CORS_ORIGINS.
Health check
curl http://localhost:5000/Response includes the active MAILPREX_MODE.
Legacy token audit
On the host machine with Mongo access:
cd back && npm run report-legacy-tokensAsk affected users to regenerate tokens in the dashboard (mk_live_… format).
Last updated on