A Postfix box receiving and submitting mail in 2026 must speak TLS — opportunistic on port 25 between MX hosts, and required-with-auth on 587 and 465 for end users and apps. This article is the configuration we apply once the install in postfix-install-ubuntu is verified: certificates in place, ciphers sane, SASL wired to Dovecot, and the two submission listeners verified with openssl s_client before any human MUA is pointed at them.
How to verify
Before changing anything, audit what is presented today. Most installs ship with smtpd_use_tls = no and a self-signed snake-oil certificate — neither is acceptable in production.
sudo postconf | grep -E 'smtpd_tls|smtp_tls|smtpd_sasl'
openssl s_client -connect localhost:25 -starttls smtp -servername mx1.example.com </dev/null 2>&1 | head -25
openssl s_client -connect localhost:587 -starttls smtp -servername mx1.example.com </dev/null 2>&1 | head -25
openssl s_client -connect localhost:465 -servername mx1.example.com </dev/null 2>&1 | head -25
ss -ltnp | grep -E ':(25|465|587)\b'
The s_client output should show your real certificate’s CN/SAN, a TLS 1.2+ negotiation, and a 250-STARTTLS capability on 25 and 587. On 465 the connection is implicit TLS — no STARTTLS, the handshake happens first.
What’s happening
Postfix exposes three SMTP services that look similar but mean different things:
- Port 25 (smtpd) — MX-to-MX. STARTTLS is opportunistic (RFC 7672 / MTA-STS). You publish a cert; peers that support TLS will use it, peers that don’t fall back to cleartext. You do not require auth here — port 25 is for the world to send you mail.
- Port 587 (submission) — MUA-to-MTA. STARTTLS is required (RFC 6409). Auth is required. This is where Thunderbird, Outlook, and your app servers submit outgoing mail.
- Port 465 (smtps / submissions) — MUA-to-MTA, implicit TLS. Handshake before the SMTP banner. Re-blessed by RFC 8314 after years of being deprecated; modern clients prefer it because there is no plaintext window.
The cert needs to match the FQDN clients connect to. Use Let’s Encrypt via certbot in standalone or DNS-01 mode, or pull from your internal PKI. Postfix reads the cert and key files at start, and re-reads on reload — no daemon restart required for cert rotation.
SASL authentication on 587/465 is delegated to Dovecot via a UNIX socket. Postfix’s smtpd talks to Dovecot’s auth socket; Dovecot validates the password against its userdb/passdb. See Dovecot install for the matching Dovecot side.
The procedure
-
Provision a certificate for the mail FQDN. Let’s Encrypt with DNS-01 keeps you off port 80; standalone HTTP-01 works if you can free port 80 briefly:
sudo apt install -y certbot sudo certbot certonly --standalone -d mx1.example.com \ --post-hook "systemctl reload postfix dovecot" ls -l /etc/letsencrypt/live/mx1.example.com/The post-hook is what triggers the reload at renewal time three months from now. Without it, the cert rotates and the daemons keep serving the old one.
-
Wire TLS into
main.cf. These are the parameters we set in every install — TLS 1.2 minimum, modern ciphers, log enough to debug but not enough to flood:smtpd_tls_cert_file = /etc/letsencrypt/live/mx1.example.com/fullchain.pem smtpd_tls_key_file = /etc/letsencrypt/live/mx1.example.com/privkey.pem smtpd_tls_security_level = may smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3,!TLSv1,!TLSv1.1 smtpd_tls_mandatory_ciphers = high tls_high_cipherlist = ECDHE+AESGCM:ECDHE+CHACHA20:!aNULL:!MD5 # client side (delivering to remote MX) smtp_tls_security_level = may smtp_tls_loglevel = 1 smtp_tls_session_cache_database = btree:${data_directory}/smtp_scachemayon the server side means “advertise STARTTLS but accept cleartext if the peer doesn’t TLS.” On the client side,maymeans the same in the outbound direction. Do not useencrypton 25 — it will refuse all peers that don’t speak TLS. -
Enable submission (587) and smtps (465) in
master.cf. Find and uncomment the two stanzas, then add the overrides:submission inet n - y - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_tls_auth_only=yes -o smtpd_reject_unlisted_recipient=no -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_relay_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING smtps inet n - y - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_relay_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATINGThe key flags:
smtpd_tls_wrappermode=yesmakes 465 implicit-TLS;smtpd_tls_security_level=encryptmakes 587 require STARTTLS before auth. -
Configure SASL via Dovecot. Add to
main.cf:smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous, noplaintext smtpd_sasl_tls_security_options = noanonymous broken_sasl_auth_clients = yesThe path is relative to
/var/spool/postfix/— the actual socket lives at/var/spool/postfix/private/auth, exposed by Dovecot’sservice auth { unix_listener /var/spool/postfix/private/auth { ... } }block. -
Reload, check, and verify each port. Reload triggers a cert re-read; check catches typos before the listener crashes:
sudo postfix check sudo systemctl reload postfix ss -ltnp | grep -E ':(25|465|587)\b' openssl s_client -connect mx1.example.com:587 -starttls smtp -servername mx1.example.com </dev/null openssl s_client -connect mx1.example.com:465 -servername mx1.example.com </dev/nullBoth should show the Let’s Encrypt cert chain,
Verify return code: 0 (ok), and TLS 1.3 (or 1.2 minimum). -
Smoke-test auth with swaks. Install
swaksif not present; it scripts an authenticated submission cleanly:swaks --to you@external.com --from user@example.com \ --server mx1.example.com:587 -tls \ --auth LOGIN --auth-user user@example.com --auth-password 'app-password'The log on the server should show
submission/smtpd[...]: ... sasl_method=LOGIN, sasl_username=user@example.com.
Common pitfalls
- The Let’s Encrypt cert is renewed without a post-hook, so the new cert lands but Postfix keeps serving the old in-memory cert until restart; we always set
--post-hookat issuance time. smtpd_tls_security_level = encrypton port 25 silently refuses mail from any peer that doesn’t STARTTLS — a measurable share of legitimate senders still don’t; keep 25 atmay.- The Dovecot socket path is wrong, and Postfix logs
warning: SASL: Connect to /var/spool/postfix/private/auth failed— Dovecot’sservice authblock must declare the listener under the postfix chroot path and chown itpostfix:postfix. - Port 465 returns
Connection refusedbecausesmtpd_tls_wrappermode=yeswas added tosubmissioninstead ofsmtps; the two listeners look similar but the wrappermode flag must live on the implicit-TLS service. - Modern MUAs reject TLS 1.0/1.1 — if you leave the
mandatory_protocolsline at the default, clients on macOS Mail and recent Outlook will refuse to negotiate.
Stack Harbor stands up the TLS edge of Postfix as a single artifact — cert provisioned, hooks attached, 587 and 465 both verified by openssl s_client from outside the network before handing the box back to the client. If you are running a Postfix that still has snake-oil on it or a port 587 that nobody has logged into in months, that audit is part of the work covered by our Managed Operations practice.