OpenSMTPD

Installieren mit:

apt install opensmtpd opensmtpd-filter-senderscore mariadb-client mariadb-server

Dann die Datei /etc/smtpd.conf anpassen. Meine sieht jetzt so aus:

pki "mail.domain.tld" cert "/etc/letsencrypt/live/mail.domain.tld/fullchain.pem"
pki "mail.domain.tld" key "/etc/letsencrypt/live/mail.domain.tld/privkey.pem"
srs key "lassdirwasschöneseinfallenhier"

# internal aliases to root
table aliases file:/etc/mail/aliases

# External Mails in Database vmail
table domains mysql:/etc/mail/mysql.conf
table virtuals mysql:/etc/mail/mysql.conf
table credentials mysql:/etc/mail/mysql.conf

filter check_rdns phase connect match !rdns \
    disconnect "550 no rDNS"

filter senderscore \
    proc-exec "filter-senderscore -junkBelow 70 -slowFactor 5000"

filter rspamd proc-exec "filter-rspamd"

listen on eth0 tls pki mail.domain.tld filter { senderscore, rspamd, check_rdns }
listen on eth0 port 465 smtps pki mail.domain.tld auth <credentials> filter { rspamd }
listen on eth0 port 587 tls-require pki mail.domain.tld auth <credentials> filter { rspamd }

action "local_mail" mbox alias <aliases>
action "domain_mail" maildir "/var/vmail/%{dest.domain:lowercase}/%{dest.user:lowercase}" virtual <virtuals>
action "outbound" relay
action "RECV" lmtp "/var/run/dovecot/lmtp" rcpt-to virtual <virtuals>

# match from any for domain <domains> action "domain_mail"
match from any for domain <domains> action "RECV"
match from local for local action "local_mail"

match from local for any action "outbound"
match auth from any for any action "outbound"

Die oben erwähnte /etc/mail/mysql.conf sieht bei mir folgendermasen aus, das muss man dann eben auf sein Datenbankschema anpassen, aber zum dokumentieren der Syntax einmal hier:

host            localhost
username        vmail
password        DatenbankPasswort
database        vmail

query_alias SELECT destination FROM virtuals WHERE email=?;
query_credentials SELECT user, password FROM credentials WHERE user=?;
query_domain SELECT domain FROM domains WHERE domain=?;