Relaying through a smarthost
The typical "the server sends notifications through an external SMTP"
setup (main.cf):
Sending and receiving mail — config, the queue, logs, typical delivery debugging.
postconf -n
the effective config
mailq
what's in the queue
postqueue -f
force the queue to flush
postcat -q <QUEUEID>
look at a message in the queue
journalctl -u postfix
or /var/log/mail.log
sudo postmap /etc/postfix/sasl_passwd && sudo systemctl reload postfix
echo "test" | mail -s "subject" you@example.com
a test message
Postfix is an MTA (mail transfer agent): it sends, receives and routes
email over SMTP. Often installed just for a server's outgoing
notifications. The postfix service runs under systemd; the config is
/etc/postfix/main.cf.
The typical "the server sends notifications through an external SMTP"
setup (main.cf):
mailq shows the reason next to each message. Logs:
journalctl -u postfix or /var/log/mail.log. Common causes: the
recipient rejected it, there's no reverse DNS (PTR), or port
25 is blocked by the provider (in which case, send through
relayhost:587).
Postfix doesn't forward mail for strangers (anti-relay). For your own
networks, use mynetworks; for authenticated senders, SASL. Don't run an
open relay (it leads to spam and blocklisting).
You need SPF/DKIM/DMARC records in DNS and a correct PTR (rDNS). Without them, large providers filter it out.
After editing sasl_passwd/transport/virtual, always run
postmap file (rebuild the .db) and reload.
It's only listening on localhost (inet_interfaces = loopback-only), or
the port is blocked (firewall). Check ss -tlnp | grep :25 and
postconf inet_interfaces.
Danger.
postsuper -d ALLpermanently deletes every message in the queue, including ones that could still be delivered — checkmailqfirst, and delete selectively by ID or scope the command (ALL deferred). An open relay (forwarding other people's mail without restrictingmynetworks/SASL) quickly gets the server blocklisted — rebuilding an IP's reputation takes weeks.
Found an inaccuracy? Report an error in the article