Simple SMTP relay with Postfix - send email from containers easily
1.7K
Simple SMTP relay for Docker — send email from any container via Gmail, SES, SendGrid, or any SMTP provider.
Every Docker app needs to send email — password resets, notifications, alerts. Instead of configuring SMTP in every app, run one relay and point everything at it.
smtp-relay:25, no auth neededdocker run -d --name smtp-relay \
-e SMTP_HOST=smtp.gmail.com \
-e SMTP_PORT=587 \
-e [email protected] \
-e SMTP_PASSWORD=your-app-password \
zachbg/smtp-relay
docker run -d --name smtp-relay \
-e SMTP_HOST=email-smtp.us-east-1.amazonaws.com \
-e SMTP_PORT=587 \
-e SMTP_USER=AKIAIOSFODNN7EXAMPLE \
-e SMTP_PASSWORD=your-ses-smtp-password \
zachbg/smtp-relay
services:
smtp:
image: zachbg/smtp-relay
restart: unless-stopped
environment:
- SMTP_HOST=smtp.gmail.com
- SMTP_PORT=587
- SMTP_USER=${SMTP_USER}
- SMTP_PASSWORD=${SMTP_PASSWORD}
# Any app — just point SMTP to "smtp:25"
app:
image: your-app
environment:
- SMTP_HOST=smtp
- SMTP_PORT=25
| Variable | Default | Description |
|---|---|---|
SMTP_HOST | Upstream SMTP server (empty = direct delivery) | |
SMTP_PORT | 587 | Upstream SMTP port |
SMTP_USER | Upstream auth username | |
SMTP_PASSWORD | Upstream auth password | |
SMTP_FROM | Override From address for all mail | |
SMTP_TLS | yes | Use TLS for upstream connection |
RELAY_NETWORKS | 10.0.0.0/8,... | Networks allowed to relay (Docker defaults) |
HOSTNAME | smtp-relay | SMTP banner hostname |
| Provider | SMTP_HOST | SMTP_PORT | Notes |
|---|---|---|---|
| Gmail | smtp.gmail.com | 587 | Use App Password |
| AWS SES | email-smtp.REGION.amazonaws.com | 587 | SMTP credentials from SES |
| SendGrid | smtp.sendgrid.net | 587 | Username: apikey |
| Mailgun | smtp.mailgun.org | 587 | |
| Outlook | smtp.office365.com | 587 | |
| Fastmail | smtp.fastmail.com | 465 |
# Send test email
docker exec smtp-relay sh -c 'echo "Test from Docker" | mail -s "Test" [email protected]'
MIT
Content type
Image
Digest
sha256:d8cd49fa2…
Size
11.6 MB
Last updated
6 months ago
docker pull zachbg/smtp-relay