Read the contents of a message in the Postfix queue
Find a queue ID with mailq, inspect its envelope, headers, or body with postcat, and distinguish message content from delivery diagnostics.
If mailq is provided by Postfix, use postcat -q QUEUE_ID to inspect a queued message. mailq lists the queue; it does not display the full message content.
mailq
postcat -q A705238B4C
postcat -bh -q A705238B4C
postcat -h -q A705238B4C
postcat -b -q A705238B4C
The first postcat command shows envelope information and message content. -bh selects headers and body without the envelope; -h selects headers and -b selects the body. Reading queue files requires suitable permissions, so an administrator may need sudo.
Copy the ID without its status marker
The first column in a traditional queue listing can look like A705238B4C*. The suffix is not part of the ID:
| Marker | Meaning |
|---|---|
* |
Selected for delivery in the active queue |
! |
Held; no delivery attempts until released |
# |
Forced to expire, supported since Postfix 3.5 |
Use the exact ID without the marker. Do not assume every ID is a short hexadecimal string: Postfix also supports long queue IDs.
Inspect selected headers across the queue
Postfix 3.1 or later supports structured queue output. With jq installed:
set -o pipefail
postqueue -j | jq -r '.queue_id' | while IFS= read -r id; do
printf '\n=== %s\n' "$id"
sudo postcat -h -q "$id" | grep -E '^(From|To|Subject|Date):'
done
Sample a few messages before inspecting a large queue. Headers can contain personal or sensitive information. The filter shows only the first line of matching headers; it does not unfold continuation lines or decode MIME-encoded subjects. Use a mail parser when you need the complete interpreted values.
The queue can change during enumeration. An ID may disappear between listing and reading, and the listing itself is not a consistent snapshot. A missing queue file can simply mean delivery finished.
Let Postfix locate the files
postconf queue_directory
The directory is often /var/spool/postfix. incoming contains newly queued mail, active contains messages selected for delivery, deferred contains delayed mail, and hold contains held messages. bounce stores per-message delivery-status information; it is not simply a mailbox of readable bounce emails. Queue storage may use hashed subdirectories, so use postcat -q rather than guessing a pathname.
Separate inspection from queue management
For delayed mail, inspect mailq, postqueue -j, and the logs for the recipient's delay reason. Original message headers do not necessarily explain a later delivery failure. Correlate the queue ID with DNS, routing, authentication, or remote-policy errors.
postqueue -f
sudo postsuper -h A705238B4C
sudo postsuper -H A705238B4C
sudo postsuper -d A705238B4C
These commands respectively request a queue flush, hold, release, and delete a message. They change state; deletion is permanent, and repeated full-queue flushes can worsen performance. If spam is accumulating, identify the submitting account or application before deleting the backlog. A forged From header alone does not identify the actual source.
References
Related reading
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan