Minimal SMTP relay docker image using Exim4 running on an Alpine Linux base. The default configuration is as a smarthost relay — for sending emails from your docker cluster to an email delivery service like Sparkpost, SendGrid, or Amazon Simple Email Service.
Thanks to Alpine Linux the uncompressed image size is a tiny 8 MB (compared to 175 MB using Debian)!
TIP: If you need to get emails from your other containers to this one, consider adding sSMTP to your existing images. This way you don't need to set up anything fancy in your applications, just use Linux's standard way of sending emails via /usr/sbin/sendmail
.
If you're on the command-line you can run:
docker run -d \
--name your-smtp \
-v /mnt/your-data-dir/smtp:/var/spool/exim:rw \
-e LOCAL_DOMAINS="@" \
-e RELAY_TO_DOMAINS="smtp.sparkpostmail.com : email.yourdomain.com" \
-e RELAY_FROM_HOSTS="192.168.0.0/16 ; *.yourdomain.com" \
-e SMARTHOST_HOST="smtp.sparkpostmail.com" \
-e SMARTHOST_PORT="587" \
-e SMARTHOST_USERNAME="SMTP_Injection" \
-e SMARTHOST_PASSWORD="your_sparkpost_api_token" \
wearegenki/smtp:latest
- The container listens for incoming connections on port
2525
(high port number so the container doesn't need theNET_BIND_SERVICE
capability). - Port 2525 is open to your internal Docker network. If you need to expose this publicly to connect from a different network add
-p 2525:2525/tcp
to your docker run command. - The separating delimiters are different for LOCAL_DOMAINS or RELAY_TO_DOMAINS (
:
colons) and RELAY_FROM_HOSTS (;
semicolons).
ISC. See LICENCE.md.
Proudly made by Max Milton <max@wearegenki.com>.
© We Are Genki