Skip to content

Debian 13: shared preparation

These guides target Debian 13 with Postfix. You do not need RateMyMail source code, Go, our domains, keys or scripts. Each feature has a setup section and a CLI test. Work as root, for example with sudo -i.

Set your own values

Replace all five example values first. 192.0.2.10 is reserved for documentation and cannot operate a public mailserver. REPORT_MAILBOX must be a real mailbox that receives mail.

set -euo pipefail
install -d -m 0700 /root
cat > /root/mailserver.env <<'EOF'
export DOMAIN=example.net
export MAILHOST=mail.example.net
export MAILBOX=postmaster@example.net
export PUBLIC_IPV4=192.0.2.10
export REPORT_MAILBOX=dmarc@example.net
EOF
chmod 0600 /root/mailserver.env
. /root/mailserver.env

The following pages load this file, so you enter your values only once. Do not put private keys or passwords in it.

Packages and Postfix

Use this base block on a fresh server without an existing MTA configuration. On an operating server, add the packages and merge changes into your existing domains, virtual mailboxes, relay and Milter settings instead of applying this block unchanged. It provides basic local domain delivery; it does not configure IMAP or user authentication.

set -euo pipefail
. /root/mailserver.env
export DEBIAN_FRONTEND=noninteractive
printf 'postfix postfix/mailname string %s\npostfix postfix/main_mailer_type select Internet Site\n' "$DOMAIN" | debconf-set-selections
apt-get update -qq
apt-get install -y --no-install-recommends postfix rspamd redis-server \
  opendkim opendkim-tools openssl gnupg gpg-wks-client \
  python3 python3-dkim python3-dnspython curl jq swaks libnet-ssleay-perl \
  bind9-dnsutils unbound ca-certificates certbot iproute2
postconf -e "myhostname=$MAILHOST" "mydomain=$DOMAIN" 'myorigin=$mydomain'
postconf -e 'mydestination=$myhostname, localhost.$mydomain, localhost, $mydomain'
postconf -e 'mynetworks=127.0.0.0/8 [::1]/128'
postconf -e 'smtpd_relay_restrictions=permit_mynetworks,reject_unauth_destination'
postconf -e 'home_mailbox=Maildir/'
postfix check
systemctl enable --now postfix
systemctl restart postfix
systemctl is-active postfix

Postfix listens for SMTP after installation. Open public firewall ports after checking TLS and relay restrictions. Local mailboxes require suitable Unix users; virtual mailboxes and Dovecot are outside this base recipe.

Choose a webserver

Choose one webserver for the MTA-STS and WKD HTTPS endpoints. The selection above the code blocks also applies on subsequent pages. Run only the matching variant; Nginx and Apache cannot bind the same ports simultaneously. Reuse an existing webserver.

set -euo pipefail
apt-get install -y --no-install-recommends nginx
nginx -t
systemctl enable --now nginx
set -euo pipefail
apt-get install -y --no-install-recommends apache2
a2enmod ssl headers
apache2ctl configtest
systemctl enable --now apache2

DNS and public prerequisites

Set A and MX at your DNS provider, and PTR at your IP provider:

example.net.       IN MX 10 mail.example.net.
mail.example.net.  IN A     192.0.2.10

Replace the domain and IP with the values in your configuration file. Feature pages add SPF, DKIM, DMARC, TLS-RPT, MTA-STS and TLSA. DNSSEC requires zone signing and a matching registrar DS. Publicly trusted certificates require control of the names and reachable ACME challenges.

Recommended order

  1. SMTP TLS, HELO and PTR.
  2. Rspamd, DKIM and oversigning.
  3. SPF and DMARC, covering every legitimate sending route.
  4. DNSSEC, DANE, MTA-STS and TLS-RPT.
  5. OpenPGP, a mailbox pin or S/MIME in the signing user's account.

Validation and evidence describes the CLI checks actually executed and separates local function tests from external DNS and ACME acceptance.