Viewing email in Linux using postfix’s mailq and postcat | Jeff Geerling
Posted by jpluimers on 2023/09/22
Since mail mostly “works” I use these below commands only very little and tend to forget them.
Luckily they were documented at [Wayback/Archive] Viewing email in Linux using postfix’s mailq and postcat | Jeff Geerling
Here are the most common commands I use when either developing or troubleshooting email in production:
mailq– print a list of all queued mailpostcat -vq [message-id]– print a particular message, by ID (you can see the ID along inmailq‘s output)postqueue -f– process the queued mail immediatelypostsuper -d ALL– delete ALL queued mail (use with caution—but handy if you have a mail send going awry!)
Via [Wayback/Archive] postfix process queue – Google Search two interesting answers (thanks [Wayback/A] Nicolas for asking):
- [Wayback/Archive] lubry answering [Wayback/Archive] linux – Postfix – how to retry delivery of mail in queue? – Server Fault:
I’m usually using this command
postsuper -r ALL && postqueue -fParameter:
-r ALLis requeue all message
-fis Flush the queue: attempt to deliver all queued mail. - [Wayback/Archive] araqnid answering [Wayback/Archive] linux – Postfix – how to retry delivery of mail in queue? – Server Fault:
postqueue -s domain.tldshould cause the backup relay machine to flush all the email for your site. The default setup for postfix enables per-site flushing for all domains inrelay_domains.postqueue -fwill do this too, but will also push out mail for external sites, i.e. it does more than you need.
Remember there are multiple queues as per:
- [Wayback/Archive] Postfix Mail Queue Management
All mails which postfix handles will stay in the server in one of these queues until the message leaves from the server.- maildrop
- hold
- incoming
- active
- deferred
- Corrupt
- [Wayback/Archive] Postfix Bottleneck Analysis
$ qshape -s hold | head T 5 10 20 40 80 160 320 640 1280 1280+ TOTAL 486 0 0 1 0 0 2 4 20 40 419 yahoo.com 14 0 0 1 0 0 0 0 1 0 12 extremepricecuts.net 13 0 0 0 0 0 0 0 2 0 11 ms35.hinet.net 12 0 0 0 0 0 0 0 0 1 11 winnersdaily.net 12 0 0 0 0 0 0 0 2 0 10 hotmail.com 11 0 0 0 0 0 0 0 0 1 10 worldnet.fr 6 0 0 0 0 0 0 0 0 0 6 ms41.hinet.net 6 0 0 0 0 0 0 0 0 0 6 osn.de 5 0 0 0 0 0 1 0 0 0 4-
The “T” column shows the total (in this case sender) count for each domain. The columns with numbers above them, show counts for messages aged fewer than that many minutes, but not younger than the age limit for the previous column. The row labeled “TOTAL” shows the total count for all domains.
-
In this example, there are 14 messages allegedly from yahoo.com, 1 between 10 and 20 minutes old, 1 between 320 and 640 minutes old and 12 older than 1280 minutes (1440 minutes in a day).
-
My related blog posts:
- Inspecting Postfix’s email queue – Tech-G
- Some scripts and tips for easing the maintenance of a postfix based SMTP system
–jeroen






Leave a comment