Locking the mail server's outbound gate: the SASL concept, setting up the Dovecot auth socket that Postfix borrows, configuring smtpd_sasl_auth_enable and smtpd_sasl_type, requiring authentication on the submission port, and choosing secure authentication mechanisms and testing them with swaks.

So far, anyone could send email through your Postfix as long as the destination was allowed — there's been no check on who's sending. In this episode we lock the outbound gate: authentication.
The core concept is SASL (Simple Authentication and Security Layer): a standard layer for authentication on top of protocols. Postfix doesn't need to manage its own password database — it "borrows" Dovecot's authentication capability via a Unix socket, so one set of credentials serves both sending and reading.
We'll set up the Dovecot auth socket, configure Postfix to use it, require authentication on the submission port, and test the result with swaks.
SASL separates the protocol (SMTP/IMAP) from the authentication mechanism. Instead of every protocol implementing its own login, they query the same SASL layer. In our architecture:
The result: passwords are stored in one place, a single source of truth, and there's no credential synchronization between Postfix and Dovecot.
Dovecot provides the auth service that serves SASL requests. We need to make it reachable by Postfix from inside its chroot. Enable it in conf.d/10-master.conf:
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
}The first socket is used by Postfix for SASL; the second is used internally by Dovecot for userdb lookups. Reload:
sudo dovecot reload
ls -la /var/spool/postfix/private/authIf the socket appears with the postfix user, the connection path is open.
Connect Postfix to the Dovecot socket and enable authentication:
sudo postconf -e 'smtpd_sasl_type = dovecot'
sudo postconf -e 'smtpd_sasl_path = private/auth'
sudo postconf -e 'smtpd_sasl_auth_enable = yes'
sudo postconf -e 'smtpd_sasl_security_options = noanonymous'
sudo postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination'
sudo postfix reloadWhat the parameters mean:
smtpd_sasl_type = dovecot — use the Dovecot SASL backend.smtpd_sasl_path = private/auth — the socket path relative to the Postfix queue directory.smtpd_sasl_auth_enable = yes — turn on the AUTH mechanism in SMTP.smtpd_sasl_security_options = noanonymous — reject anonymous logins.smtpd_recipient_restrictions — now permit_sasl_authenticated lets authenticated clients send to any destination.Check that the mechanism is detected:
postconf smtpd_sasl_type smtpd_sasl_path smtpd_sasl_auth_enableRight now AUTH is available on all ports. It shouldn't be: port 25 must reject authentication (preventing spammers from using leaked credentials), while submission (587) and SMTPS (465) require it. Separate the policies in master.cf:
sudo postconf -M submission/inet='submission inet n - y - - smtpd'
sudo postconf -P submission/inet/smtpd_tls_security_level=encrypt
sudo postconf -P submission/inet/smtpd_sasl_auth_enable=yes
sudo postconf -P submission/inet/milter_macro_daemon_name=ORIGINATING
sudo postfix reloadWith this configuration, port 587 only serves clients that authenticate over TLS — a combination that forms modern mail security practice. Check the resulting master.cf:
postconf -M submission/inetauth_mechanisms in Dovecot determines how passwords are sent:
The golden rule: since TLS has been mandatory on submission since episode 6, plain login is a valid choice and the most compatible with all clients. scram-sha-256 is an upgrade for clients that support it. Never enable PLAIN without TLS.
doveadm config set auth_mechanisms 'plain login'
sudo dovecot reloadswaks (Swiss Army Knife for SMTP) is the best SMTP testing tool to make sure authentication works:
sudo apt install -y swaksTest logging in to submission with TLS:
swaks --server mail.example.com --port 587 --tls \
--auth-user admin@example.com --auth-password 'rahasia' \
--to admin@example.com --from admin@example.comIf the output ends with 250 2.0.0 Ok: queued, authentication and delivery succeeded. To make sure port 25 rejects AUTH, try without --tls on port 25 — the result must be a rejection.
Info
Use --tls and not --tls-optional in swaks. A "queued" result only means something when encryption is actually active — that's what proves the password didn't cross in plaintext.
Episode 13 is done. Key takeaways:
/var/spool/postfix/private/auth connects the two.permit_sasl_authenticated lets authenticated clients send anywhere.swaks --tls.The outbound gate is locked. In episode 14 we fight the junk: Anti-Spam — SpamAssassin & RBL — installing rule-based scoring, learning from email history, and rejecting well-known IPs at the start of the connection. See you in episode 14!