E-Mail Services
E-Mail Services focuses on Postfix and Dovecot: accepting mail, routing aliases and virtual domains, queue management, TLS, and IMAP/POP3 delivery. You need to trace a message from SMTP ingress to mailbox.
Core rules
- Postfix
main.cfkeys includemyhostname,mydomain,myorigin,inet_interfaces,mydestination,relayhost,home_mailbox = Maildir/, andvirtual_alias_maps.postconf -nshows non-default settings;postfix checkvalidates. - Local aliases are in
/etc/aliases, applied withnewaliases. Virtual aliases use a hash map:virtual_alias_maps = hash:/etc/postfix/virtual, thenpostmap /etc/postfix/virtual; a virtual domain should not also be inmydestination. - Queue tools:
mailq,postqueue -f,postsuper -d ALL,postcat -q QUEUEID. TLS usessmtpd_tls_cert_file,smtpd_tls_key_file, andsmtpd_use_tls=yes; test withopenssl s_client -starttls smtp -connect mail:25. - Dovecot separates
passdb/userdband mail location:mail_location = maildir:~/Maildir,protocols = imap pop3, and TLS cert/key settings.doveadminspects mailboxes.
Worked example
Forward all mail for [email protected] to [email protected]. Add virtual_alias_maps = hash:/etc/postfix/virtual; create /etc/postfix/virtual with [email protected] [email protected]; run postmap /etc/postfix/virtual, postfix check, reload. Reasoning: Postfix rewrites the envelope recipient through the virtual alias map before delivery; the target is external, so no local mailbox is needed. If example.com were in mydestination, local delivery would win and the alias would not behave as intended.
Traps
Editing /etc/aliases without newaliases; editing a hash map without postmap; leaving a virtual domain in mydestination; wrong Maildir path so Dovecot shows an empty inbox; key files readable by non-postfix users; and an open relay from an overly broad mynetworks.