To read Postfix mail logs for troubleshooting, find the queue ID of the message in the mail log, then follow every line that carries that ID from smtpd (receive) through qmgr and cleanup to smtp or lmtp (delivery). The status= field on the final line (sent, deferred or bounced) and the text after it tell you why a message did or did not leave. This is the core of Postfix mail log troubleshooting.
Postfix logs every step of a message's life, so a few grep commands usually find the cause of a missing email in under a minute. This article assumes Postfix is already running on a Linux server.
Postfix logs through syslog or the systemd journal. Where you read them depends on the distribution.
| System | Command or file |
|---|---|
| Debian or Ubuntu with rsyslog | /var/log/mail.log |
| RHEL, Rocky, Alma, Fedora with rsyslog | /var/log/maillog |
| Any systemd system (including minimal images without rsyslog) | journalctl -u postfix |
Recent Postfix releases can also log straight to a file with maillog_file = /var/log/postfix.log in main.cf, which is common in containers where there is no syslog daemon. Check which one you use before you start searching:
On some systems the unit is postfix.service, on others a per-instance unit such as [email protected]. If one returns nothing, try the other.
A typical line looks like this:
| Part | Meaning |
|---|---|
postfix/smtp[2841] | The Postfix daemon that wrote the line (smtp is the outbound delivery agent) and its process ID |
4F2A81C0B2 | The queue ID, the key that ties all lines of one message together |
to=<...> | The recipient of this delivery attempt |
relay= | The host and port Postfix talked to |
delay=1.4 | Total seconds since the message arrived |
delays=a/b/c/d | Time before queue manager, in queue manager, connection setup, transmission |
dsn=2.0.0 | The enhanced status code (2.x.x success, 4.x.x temporary, 5.x.x permanent) |
status=sent | The outcome of this attempt |
The text in parentheses at the end is usually the remote server's own reply, which is the most useful clue you have.
Start from something you know, such as a recipient address or a time, and find the queue ID:
Then pull every line for that ID:
A complete successful inbound-then-outbound message shows lines like these, in order:
If the message stops before removed, it is still in the queue, and the last line tells you where it stalled.
The next server accepted the message. If the recipient still does not see it, the problem is after your server: the remote side may have filed it as spam. Quote the remote queue ID (queued as 7B31E20F4) to that server's administrator.
A temporary failure. Postfix keeps the message and retries, by default for up to five days (maximal_queue_lifetime). Common causes:
Connection timed out or Connection refused: a firewall, wrong port, or the remote server is down. Many hosting providers block outbound port 25.Host or domain name not found: a DNS problem on either side.450 or 451 replies with words like "greylisted" or "try again later": the remote server is deliberately delaying you. Retries normally fix it.TLS is required, but was not offered or certificate errors: a TLS policy mismatch.A permanent failure. Postfix gives up and sends a non-delivery report to the sender. Typical causes:
550 5.1.1 User unknown: the recipient address does not exist.550 5.7.1 with a message about SPF, DKIM, DMARC or a blocklist: the receiver rejected you for reputation or authentication reasons.554 5.7.1 Relay access denied: you tried to relay through a server that does not accept your mail, or your own server rejected a client that is not allowed to relay.These one-liners answer most real questions:
Lines with NOQUEUE mean Postfix refused the message during the SMTP conversation, before accepting it, so there is no queue ID. The reason follows, for example Recipient address rejected: User unknown in virtual mailbox table.
The pflogsumm tool, packaged as postfix-pflogsumm on some systems, summarises a day of logs into counts of messages, top senders and bounce reasons.
Normal logging hides TLS and SMTP conversation details. To see more for one problem host only, avoid turning on full debugging for everything. Use debug_peer_list and debug_peer_level in main.cf:
Run sudo postfix reload, reproduce the problem, read the log, then remove both lines and reload again. Leaving debug on fills the disk quickly and can write sensitive content to the log.
Either the message never reached Postfix (check the sending application's own error and the smtpd lines for connection attempts), or you are reading the wrong log. Search the journal and the other file name from the table above.
Read the four numbers in delays=. A large third value points to slow DNS or connection setup, a large fourth value to a slow remote server, and a large second value to a backed-up queue.
That depends on your logrotate configuration, usually a few weeks. Keep logs long enough to investigate a complaint from a customer who writes days later.
No. Postfix logs envelope data and headers such as the Message-ID, not the body. To inspect a queued message, use postcat -q QUEUEID as described in the article on the queue.
Find the queue ID, grep every line for it, and read the status= and the remote reply on the last smtp line. sent means the next hop accepted it, deferred means Postfix will retry, and bounced means a permanent failure that needs a fix on your side or the recipient's. Use NOQUEUE: reject for messages refused at the door and journalctl when no log file exists.