Mini Mailer is a simple SMTP server that forwards mail over HTTP to Mailgun, Postmark, or MailerSend. For use as an SMTP gateway on platforms (e.g. Railway) that restrict outbound SMTP ports.
Mini Mailer does not support attachments and is designed to run on an internal network only (e.g. mini-mailer.railway.internal), as it does not use TLS.
- Listens for SMTP connections (e.g. on port 25, 2525, or 587).
- Requires SMTP username + password.
- Uses the username first, then the password, to choose the provider.
- Forwards each message to the right provider over HTTPS.
| Setting | Default | Env var |
|---|---|---|
| Host | 0.0.0.0 |
LISTEN_HOST |
| Health | 80 |
HEALTH_PORT |
- Use port 25, 2525, or 587 (or your configured port) for SMTP.
- Use port 80 (or your configured port) for the health check.
- AUTH is required: clients must send a username and password (e.g. SMTP AUTH LOGIN/PLAIN).
- The password is used as the API key/token for the chosen provider (see below). So you configure your app or SMTP client with:
- Username: e.g.
mailgun@mg.yourdomain.com,mailgun-eu@mg.yourdomain.com,mailersend@yourdomain.com, orpostmark@yourdomain.com. The local part can be used to force the provider; for Mailgun the domain is also used as the sending domain. - Password: the API key or server token for that provider (Mailgun Sending Key, Postmark Server API Token, or MailerSend API Token).
- Username: e.g.
That way you can use different credentials per domain or app by using different SMTP usernames and passwords.
The relay chooses the provider in this order:
- If the username local part matches a provider, that provider wins.
- Otherwise, it falls back to the password and detects the provider from the API key/token pattern.
Supported username local parts:
mailersend@...-> MailerSendpostmark@...-> Postmarkmailgun@...-> Mailgun US APImailgun-eu@...-> Mailgun EU API
When Mailgun is used, the domain in the username must match the domain the API key belongs to.
For example, if you have a Mailgun API key for the domain mg.yourdomain.com, you can use the username mailgun@mg.yourdomain.com or mailgun-eu@mg.yourdomain.com, and the password will be the Mailgun Sending Key.
If Mailgun is detected from the API key instead of the username, Mini Mailer uses MAILGUN_EU to choose the Mailgun region:
MAILGUN_EU=1useshttps://api.eu.mailgun.net- unset or any other value uses
https://api.mailgun.net
For Postmark and MailerSend, the domain part of the username is ignored.
Configure your app or SMTP client to use the relay like this:
- Host: your Mini Mailer host (e.g.
mini-mailer.railway.internal). - Port:
25,2525, or587. - Username: e.g.
mailgun@mg.yourdomain.com,mailgun-eu@mg.yourdomain.com,mailersend@yourdomain.com, orpostmark@yourdomain.com. - Password: the corresponding provider API key or token (Mailgun Sending Key, Postmark Server API Token, or MailerSend API Token).
- Encryption: none
A small HTTP server runs for readiness/liveness probes (e.g. Railway). It listens on HEALTH_PORT (default 80).
- GET
/healthor GET/→200and{"status":"ok"}.
Configure your platform to use path /health on the service’s HTTP port so the health check succeeds when the process is up.
npm install
npm run build
npm run startOr for development:
npm run devOptional env vars (for logging and listen address):
LOG_LEVEL– e.g.info,debugLISTEN_HOST– default0.0.0.0HEALTH_PORT– default80(HTTP health check).SMTP_PORTS– comma-separated SMTP listen ports, defaults to25,2525,587DEFAULT_API_KEY– when set, allows unauthenticated SMTP clients and uses this API key/token as the provider credential.MAILGUN_EU– set to1to use Mailgun's EU API when Mailgun is selected by API key rather than by amailgun/mailgun-euusername.
Run the MailSlurp end-to-end suite with:
npm run test:e2eRequired env vars:
SMTP_HOST– Mini Mailer host to test againstSMTP_PORT– Mini Mailer SMTP port, defaults to2525MAILSLURP_API_KEY– MailSlurp API keyTEST_MAILGUN_USERNAME– SMTP username for Mailgun, e.g.mailgun@mg.example.comTEST_MAILGUN_API_KEY– Mailgun API keyTEST_POSTMARK_USERNAME– SMTP username for Postmark, e.g.postmark@test.example.comTEST_POSTMARK_API_KEY– Postmark server tokenTEST_POSTMARK_FROM– verified Postmark sender addressTEST_MAILERSEND_USERNAME– SMTP username for MailerSend, e.g.mailersend@test.example.comTEST_MAILERSEND_API_KEY– MailerSend API keyTEST_MAILERSEND_FROM– verified MailerSend sender address