When email is delayed, the answer is usually in the mail queue: messages the server accepted but could not deliver yet. This guide is a practical reference for managing the mail queue on Exim (cPanel, DirectAdmin) and Postfix (Plesk, many self-built servers) from SSH.
Before you start
- Root SSH access to the mail server.
- On cPanel you can also use WHM → Email → Mail Queue Manager; the commands below are faster for large queues.
Warning: Deleting queued messages is permanent. Inspect before you delete, and never wipe the whole queue unless you are sure it contains only spam.
Exim queue commands
| Task | Command |
|---|---|
| Count messages | exim -bpc |
| List queue | exim -bp |
| Summary by domain | exim -bp | exiqsumm |
| Show headers | exim -Mvh MESSAGE-ID |
| Show body | exim -Mvb MESSAGE-ID |
| Show message log | exim -Mvl MESSAGE-ID |
| Retry one message | exim -M MESSAGE-ID |
| Run the queue | exim -qff |
| Remove one message | exim -Mrm MESSAGE-ID |
| Remove frozen messages | exiqgrep -z -i | xargs exim -Mrm |
| Messages from a sender | exiqgrep -f sender@example.com -i |
| Messages to a domain | exiqgrep -r example.net -i |
Exim's main log is /var/log/exim_mainlog. Trace one message with exigrep MESSAGE-ID /var/log/exim_mainlog.
Postfix queue commands
| Task | Command |
|---|---|
| List queue | postqueue -p (or mailq) |
| Count messages | postqueue -j | wc -l (Postfix 3.1+) |
| Show a message | postcat -vq QUEUE-ID |
| Retry all deferred mail | postqueue -f |
| Retry one message | postqueue -i QUEUE-ID |
| Delete one message | postsuper -d QUEUE-ID |
| Delete all deferred mail | postsuper -d ALL deferred |
| Hold / release a message | postsuper -h QUEUE-ID / postsuper -H QUEUE-ID |
Postfix logs to /var/log/mail.log, /var/log/maillog or the journal (journalctl -u postfix).
Find out why mail is deferred
- Read the reason in the queue listing or the message log.
- Common reasons:
- Connection timed out – the remote server is down, or your outbound port 25 is blocked.
- 4xx greylisting / try again later – normal; the server will retry.
- 5xx rejected / blocked – your IP or domain is on a blocklist, or SPF/DKIM fails.
- Mailbox full – the recipient's quota is exceeded.
- Fix the cause, then retry the queue.
Spotting a spam flood
A sudden queue of thousands usually means a hacked mailbox or script. Find the top senders:
exim -bp | awk '/^ *[0-9]+[mhd]/{print $4}' | sort | uniq -c | sort -rn | headThen change the compromised password, disable the script, and remove that sender's messages with exiqgrep -f and exim -Mrm. On Postfix, check postqueue -p output and the logs for the authenticated user (sasl_username).
FAQ: mail queue
How long does a server keep retrying?
Typically several days (Exim's default retry rules and Postfix's maximal_queue_lifetime of 5 days) before bouncing the message.
What is a frozen message in Exim?
A message Exim stopped trying to deliver, often a bounce that could not be returned. Frozen bounces are usually safe to delete.
Should I flush the queue repeatedly?
No. Forcing retries does not fix the underlying cause and may hurt your reputation with remote servers.
