A minimal fake SMTP server for testing. Accepts all incoming mails without sending them anywhere — stores each message as a plain-text file and logs all SMTP traffic.
Use fake-smtp wherever your stack sends outgoing email during development or CI:
npm start # foreground with logs
npm run start:daemon # background
Then send a test mail:
swaks --to [email protected] --from [email protected] \
--server localhost --port 2525
Or with plain netcat:
{ echo -e "EHLO test\r\nMAIL FROM:<[email protected]>\r\nRCPT TO:<[email protected]>\r\nDATA\r\nSubject: hi\r\n\r\nBody\r\n.\r\nQUIT\r\n"; sleep 1; } \
| nc localhost 2525
FAKE_SMTP_PORT, default 2525)MAIL FROM / RCPT TO without authentication or TLSDATA: writes the full raw message to /mails/<timestamp>-<from>-<to>.txt/mails/log and stderrEHLO, HELO, MAIL FROM, RCPT TO, DATA, QUITAUTH, STARTTLS, extensions# list received mails
docker compose exec fake-smtp ls /mails/
# read a mail
docker compose exec fake-smtp cat /mails/<filename>
# tail the SMTP log
docker compose exec fake-smtp tail -f /mails/log
# or mount the volume on the host and access directly
| Variable | Default | Description |
|---|---|---|
FAKE_SMTP_PORT | 2525 | Host port mapped to container port 25 |
Point any service that sends mail to fake-smtp:25:
services:
fake-smtp:
image: mwaeckerlin/fake-smtp
ports:
- "${FAKE_SMTP_PORT:-2525}:25"
volumes:
- mails:/mails
myapp:
image: myapp
environment:
SMTP_HOST: fake-smtp
SMTP_PORT: 25
volumes:
mails:
Replace the outbound relay with fake-smtp to capture mails sent by postfix/mailforward without a real internet connection:
services:
smtp-relay:
image: mwaeckerlin/fake-smtp # swap real relay
networks:
- relay-net
fake-smtp:
image: mwaeckerlin/fake-smtp
volumes:
- mails:/mails
networks:
- relay-net
Then in your test:
/mails/Content type
Image
Digest
sha256:63865363b…
Size
285.9 kB
Last updated
1 day ago
docker pull mwaeckerlin/fake-smtp