Setup
# Get All Files
DMS_GITHUB_URL="https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/master"
wget "${DMS_GITHUB_URL}/compose.yaml"
wget "${DMS_GITHUB_URL}/mailserver.env"
-
edit compose.yaml:
- append
/etc/letsencrypt:/etc/letsencrypt
to the volumes for enabling lets encrypt - change the hostname to the hostname of mail server (
mail.example.com
)
- append
-
edit
mailserver.env
(all environments are there)
ENABLE_RSPAMD=1 ENABLE_OPENDKIM=0 ENABLE_OPENDMARC=0 ENABLE_POLICYD_SPF=0 ENABLE_AMAVIS=0 ENABLE_SPAMASSASSIN=0 SSL_TYPE=letsencrypt ...
You can also add:
ENABLE_CLAMAV=0 ENABLE_FAIL2BAN=1
note: Fail2ban will reduce the spam attacks (brute force) by making the frequent requester IPs ban
# run DMS for first time
docker compose -f compose.yaml up
# create the very first account for dovecot (prompts for password)
docker exec -ti mailserver setup email add info@example.com
# add alias as it is popular to do this (forwards all of postmaster@example.com to admin@example.com)
docker exec -ti mailserver setup alias add postmaster@example.com admin@example.com
# install local dns (systemd resolve + BIND)
...
# create rspamd configs
mkdir -p ./docker-data/dms/config/rspamd/override.d/
# add the settings of Rsampd for dns (from https://rspamd.com/doc/configuration/options.html) to the override.d
cat > ./docker-data/dms/config/rspamd/override.d/options.inc <<EOF
options {
dns {
nameserver = ["127.0.0.1:53"];
}
}
EOF
# add commands like enabling classifier-bayes module (https://docker-mailserver.github.io/docker-mailserver/edge/config/security/rspamd/#with-the-help-of-a-custom-file)
cat > ./docker-data/dms/config/rspamd/custom-commands.conf <<EOF
set-option-for-module classifier-bayes autolearn true
EOF
# config DKIM by running this and save the output as TXT DNS record
# ! WARNING: IT IS ONLY FOR ONE DOMAIN, FOR MULTIPLE, CHECK THE DKIM [Docs](https://docker-mailserver.github.io/docker-mailserver/latest/config/best-practices/dkim_dmarc_spf/#rspamd)
docker exec -it mailserver setup config dkim domain example.com
# Note: Don't forget to add MX record and `mail` A record for the extra domain!
# add DMARC record with the help of some good site (https://dmarcguide.globalcyberalliance.org/dmarc)
# add SPF record
# add some alias (seems like forwarding emails to the destination)
docker exec -ti mailserver setup alias add t1@example.com t11@gmail.com
docker exec -ti mailserver setup alias add t2@example.com t22@gmail.com
# done with the installation