Run postfix with smtp authentication (sasldb) in a docker container. TLS and OpenDKIM support are included.
-
Clone the codes
git clone https://github.com/a-lang/docker-postfix-smtp.git
-
Pull the image
docker pull alangtw/postfix-smtp:trusty
-
Run the container
./run.sh
-
Create the SSL self-signed certificates for your domain, save the certificates
.key and .crt
indata/certs
docker exec -it postfix openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \ -keyout /etc/postfix/certs/smtp-mydomain-com.key \ -out /etc/postfix/certs/smtp-mydomain-com.crt
-
Create DKIM key, save your domain key
.private
indata/domainkeys
docker exec -it postfix sh -c "cd /etc/opendkim/domainkeys && opendkim-genkey -t -s mail -d mydomain.com"
-
Stop the container then re-start it
./stop.sh ./run.sh
- SMTP login credential should be set to (
username@mydomain.com
,password
) in Smtp Client - You also need to modify the DNS setting for TXT records with SPF, DKIM and DMARC info.