Postfix main.cf Complete Guide
Understand the most important main.cf controls for identity, relay policy, routing, TLS and delivery.
Use postconf
Prefer postconf for inspecting effective values and scripted changes. Keep comments explaining site-specific decisions in version-controlled configuration.
Identity parameters
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = allRelay policy
mynetworks = 127.0.0.0/8, [::1]/128
smtpd_relay_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destinationRouting
Use transport maps and sender-dependent relay maps only when the routing goal is clear. Test map lookups directly before reloading.
TLS
Choose TLS policy based on whether the service is public SMTP, authenticated submission or a controlled relay path. Do not blindly require encryption on port 25, where opportunistic TLS is the interoperable norm.
Validation
postfix check
postconf -n
postmap -q example.com hash:/etc/postfix/transport
systemctl reload postfix