Dritter Teil der “Postfix-Dovecot-MySQL”-Trilogie
localhost
erreichbar seinEin- und ausgehende SMTP-Verbindungen sollen möglichst verschlüsselt sein. Eine Authentifizierung am Postfix wird nur angeboten, wenn die Verbindung verschlüsselt ist:
sudo postconf smtpd_tls_security_level=may
sudo postconf smtpd_tls_auth_only=yes
sudo postconf smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
sudo postconf smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
sudo postconf smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
sudo postconf smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
Unser Dovecot dient uns als SASL-Backend, Postfix fragt also den Dovecot, ob eine bestimmte Username-Passwort-Kombination existiert:
sudo postconf smtpd_sasl_type=dovecot
sudo postconf smtpd_sasl_path=private/auth
sudo postconf smtpd_sasl_auth_enable=yes
SMTP-Auth sollte nicht angeboten werden, aber STARTTLS:
SMTP-Auth sollte angebten werden, sobald die Verbindung gesichert ist:
LMTP soll auch gleich TLS benutzen, egal ob über einen (lokalen) Unix-Socket oder über TCP/IP:
cat <<EOF >> /etc/postfix/master.cf
lmtps unix - - - - - lmtp
-o lmtp_use_tls=yes
-o lmtp_enforce_tls=yes
-o lmtp_tls_mandatory_protocols=!SSLv2,!SSLv3
-o lmtp_tls_protocols=!SSLv2,!SSLv3
-o lmtp_tls_mandatory_ciphers=high
-o lmtp_tls_ciphers=high
-o lmtp_send_xforward_command=yes
-o lmtp_tls_security_level=encrypt
-o lmtp_tls_note_starttls_offer=yes
-o lmtp_address_preference=ipv4
EOF
Postfix bekommt mehrere maps konfiguriert, die auf den MySQL-Server aus Postfix-Dovecot-MySQL: MySQL zugreifen. Die Zugangsdaten und SQL-Statements werden in den einzelnen Dateien hinterlegt. Daher müssen diese besonders geschützt werden und bekommen ein extra Verzeichnis, in das nur root
und postfix
wechseln dürfen:
# /etc/postfix/private/mysql_virtual_mailbox_domains.cf
user = postfix
password = ChangeMe
hosts = 127.0.0.1
dbname = mailserver
query = SELECT 1 FROM virtual_domains WHERE name='%s'
sudo postconf virtual_mailbox_domains=mysql:/etc/postfix/private/mysql_virtual_mailbox_domains.cf
sudo postmap -q example.org mysql:/etc/postfix/private/mysql_virtual_mailbox_domains.cf
# /etc/postfix/private/mysql_virtual_mailbox_maps.cf
user = postfix
password = ChangeMe
hosts = 127.0.0.1
dbname = mailserver
query = SELECT 1 FROM virtual_users WHERE email='%s'
sudo postconf virtual_mailbox_domains=mysql:/etc/postfix/private/mysql_virtual_mailbox_maps.cf
sudo postmap -q foo@example.org mysql:/etc/postfix/private/mysql_virtual_mailbox_maps.cf
# /etc/postfix/private/mysql_virtual_alias_maps.cf
user = postfix
password = ChangeMe
hosts = 127.0.0.1
dbname = mailserver
query = SELECT destination FROM virtual_aliases WHERE source='%s'
sudo postconf virtual_alias_maps=mysql:/etc/postfix/private/mysql_virtual_alias_maps.cf
sudo postmap -q bar@example.org mysql:/etc/postfix/private/mysql_virtual_alias_maps.cf
# /etc/postfix/private/mysql_virtual_alias_maps.cf
user = postfix
password = ChangeMe
hosts = 127.0.0.1
dbname = mailserver
query = (SELECT destination FROM virtual_aliases WHERE source='%s') UNION (SELECT email FROM virtual_users WHERE email='%s')
sudo postconf virtual_alias_maps=mysql:/etc/postfix/private/mysql_virtual_alias_maps.cf
sudo postmap -q bar@example.org mysql:/etc/postfix/private/mysql_virtual_alias_maps.cf