Golden Codes - armanexplorer planet

Practical code snippets for Django, Python, Bash, Git and All!

View on GitHub

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"

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

Important References

Github

Documents

Basic Installation

Rspamd

Usage

Email Ports

DKIM, DMARC & SPF

DMARC Config

SSL/TLS

Sample DMS Docker Compose

tools

R1

R2

R3

R4

R5

R6

DMARC Guide

Other References

FAQ

Env Vars

Optional Configs

setup.sh