This Docker image provides a mail transfer agent (MTA) running as a smarthost for Docker containers. The container can be used to send out e-mails from other containers.
- inherit form debian:jessie
- provide a minimal MTA Smarthost Configuration
imixs/smarthost provides the following environment variables
- EXIM_SMARTHOST - your target mail server
- EXIM_PASSWORD - authenticating to a remote host as a client.
- EXIM_ALLOWED_SENDERS - allowed sender IP/Network addresses (default=172.17.0.0/24:127.0.0.1)
1. Install Docker
Follow the Docker installation instructions for your host system.
2. Running and stopping a container
The container can be started in background as an demon. You can start an instance with the command:
docker run --name="smarthost" -d \ -e EXIM_SMARTHOST="target.mail.server.example:25" \ -e EXIM_PASSWORD="target.mail.server.example:login:password" \ imixs/smarthost
The environment parameter 'EXIM_SMARTHOST' points to the target mail sever used by exim4.
The environment parameter 'EXIM_PASSWORD' is written to the exim4/passwd file. This parameter contains the target mail server, user and login data.
To stop and remove the Docker container run the Docker command:
docker stop smarthost && docker rm smarthost
To follow the exim4 server log:
docker logs -f smarthost
To test your smarthost configuration, first log into the bash of your smarthost:
# log into bash docker exec -it smarthost /bin/bash
With the following command you can test sending out an email
echo "This is the message" | mail -s "The subject" email@example.com -aFrom:firstname.lastname@example.org
Linking the Container
You can link the smarthost Docker container to other containers in your Docker network to allow them to send out mail via the smarthost.
Take care about the default environment setting:
This environment variable defines, if other docker containers running on your docker host, are allowed to use the MTA for sending out e-mails. The default setting is "172.17.0.0/24:127.0.0.1", which allows all linked containers to send mails. Customize this parameter if you have custom needs in your docker virtual network. If the setting is not set correct, you will typically see a log message like
...exim4 IP address .. relay not permitted...
To build the image from the Dockerfile run:
docker build --tag=imixs/smarthost .