A Dockerized setup for Postfix, Dovecot, SpamAssassin, and MySQL with TLS/SSL
Clone the repo and cd into it
git clone https://github.com/BushyToaster88/dockerised-emailserver.git
cd dockerised-emailserver
Build the Dockerfile
docker build -t emailserver-mysql .
To run the container, use the following command:
docker run -d --name emailserver-mysql \
-p 25:25 \
-p 993:993 \
-p 465:465 \
-p 53:53
-e MYSQL_ROOT_PASSWORD='PASSWORD' \
-e DOMAIN='example.com' \
-e EMAIL_USER='name@example.com' \
-e EMAIL_PASSWORD='PASSWORD' \
emailserver-mysql
Once the Docker container is running, execute the setup script with:
docker exec -it emailserver-mysql python3 /app/dns_sendability.py
This command will setup letsencrypt and show you what to put into your DNS.
You will need some DNS entries to connect to your email server. First being the MX records. It will be best if you create these 5 MX records so it covers all email clients.
mail.example.com
smtp.example.com
webmail.example.com
imap.example.com
mx.example.com
Letsencrypt requires a CNAME record.
If you plan to send emails, you need to configure other records. Note that for sending emails to major email providers such as Gmail, a rDNS (Reverse DNS) record must also be configured. If you do not want to send emails, you can ignore the below DNS settings. Remove all quotes when copying.
The dkim record may have a space in it, just remove that
Run the python script to add more users to your email server.
docker exec -it mailserver python3 /app/add_user.py user@example.com password