Exim is the mail server on most cPanel and DirectAdmin servers. When it can't deliver a message straight away, it keeps it in a queue and retries. This guide is for administrators of their own server or VPS: it covers the commands to inspect the queue, deliver or remove messages safely, and clean up after a spam run.
exim -bpc counts queued messages, exim -bp lists them and exim -bp | exiqsumm summarises them by domain. exiqgrep selects messages by sender, recipient, age or frozen state, and -i prints just their IDs, which you pipe to xargs exim -Mrm to delete. exim -M MESSAGE-ID retries one message now and exim -q runs the whole queue. Never delete the whole queue as a reflex: it removes legitimate mail waiting for a retry.
These commands need root access on a server you run. On shared hosting the provider manages the mail queue; on Domain India shared hosting, open a ticket if mail is stuck (section 8).
1. How the Exim queue works
When Exim accepts a message it tries to deliver it at once. If the receiving server is down, refuses with a temporary error such as a 421, or can't be reached, the message stays in the spool (/var/spool/exim/input) and Exim retries on a schedule. After its retry time runs out, the message bounces back to the sender.
A message that Exim can't deliver or bounce, such as a bounce whose own recipient is dead, becomes frozen. Frozen messages stay until an administrator thaws or removes them, or until the server's frozen-message timeout clears them.
A large or growing queue usually means one of three things: a remote provider is rate-limiting you, your server is sending spam, or a destination is down.
2. See what is in the queue
| Command | What it shows |
|---|---|
| exim -bpc | Number of messages in the queue |
| exim -bp | Each message: age, size, ID, sender and recipients |
| exim -bp, piped to exiqsumm | Totals per recipient domain, with oldest and newest |
| exiqgrep -c ... | Count of messages matching a filter (see section 3) |
| exiwhat | What each running Exim process is doing right now |
For a quick view of where mail is going, sort the summary:
exim -bp | exiqsumm | sort -rn | head -20To look at one message:
exim -Mvh 1uAbCd-0001Xy-2Z # headers
exim -Mvb 1uAbCd-0001Xy-2Z # body
exim -Mvl 1uAbCd-0001Xy-2Z # this message's delivery logThe message log (-Mvl) is the fastest way to see why a message is stuck. The main log has the full history; it is /var/log/exim_mainlog on cPanel and /var/log/exim/mainlog on DirectAdmin, and exigrep MESSAGE-ID LOGFILE pulls out every line for one message.
3. Select messages with exiqgrep
exiqgrep reads the queue itself and filters it. Useful options:
| Option | Selects |
|---|---|
| -f address | Sender matches (a regular expression) |
| -r address | Recipient matches |
| -o seconds | Older than the given age |
| -y seconds | Younger than the given age |
| -z | Frozen messages only |
| -x | Messages that are not frozen |
| -i | Print only the message IDs |
| -c | Print only the count |
Examples:
exiqgrep -c -f '[email protected]' # how many from one sender
exiqgrep -r '@gmail\.com$' # everything to Gmail, with details
exiqgrep -z -i # IDs of frozen messages
exiqgrep -o 86400 -f '^<>$' -i # bounces older than one dayAlways run a filter with -c or without -i first, and read what it matches, before you pipe the IDs into a delete.
4. Deliver, freeze and thaw
| Command | Effect |
|---|---|
| exim -M id | Try to deliver this message now |
| exim -q | Run the queue once, respecting retry times |
| exim -qf | Run the queue and force a retry of every non-frozen message |
| exim -qff | As -qf, and also try frozen messages |
| exim -R domain | Retry messages for one recipient domain |
| exim -Mf id | Freeze a message so Exim stops trying it |
| exim -Mt id | Thaw a frozen message |
| exim -Mg id | Give up: bounce the message back to the sender |
Forcing a whole-queue run (-qf, -qff) against a provider that is rate-limiting you makes the problem worse. Fix the cause first, then let the normal retry schedule work.
5. Remove messages safely
exim -Mrm MESSAGE-ID deletes a message without delivering it or telling the sender. It accepts several IDs at once, so combine it with exiqgrep -i and xargs -r (which does nothing if no IDs match):
# frozen messages
exiqgrep -z -i | xargs -r exim -Mrm
# everything from one compromised sender
exiqgrep -f '[email protected]' -i | xargs -r exim -Mrm
# bounces older than a day
exiqgrep -o 86400 -f '^<>$' -i | xargs -r exim -Mrmexiqgrep -i | xargs -r exim -Mrm deletes every queued message, including invoices, password resets and customer replies waiting for a retry. Their senders are never told. Use it only when you have confirmed the queue is entirely spam.
6. Clean up after a spam run
A queue of thousands of messages to random addresses usually means a hacked mailbox or a PHP script sending spam. Stop the source before you delete anything, or the queue refills.
- Find the sender. Use `exim -bpexiqsumm
andexiqgrepto find the sender address or domain. On cPanel, thecwd=` field in the main log shows which folder a PHP script sent from. - Stop it.Change the password of a compromised mailbox, or disable or fix the abused script or contact form.
- Remove the spam. Delete that sender's messages with `exiqgrep -f ... -ixargs -r exim -Mrm
, then the frozen bounces withexiqgrep -z -i`. - Check your reputation.Look up your server IP on blocklists and check SPF, DKIM and DMARC, as described in the Exim 421 guide.
- Watch the queue.Run
exim -bpcagain over the next hour to confirm it stays small.
7. Panel tools
Both panels have a graphical view of the same queue. On cPanel, WHM has a Mail Queue Manager for searching, delivering and deleting queued messages. DirectAdmin has a mail queue page at admin level. Menu names change between versions; the command line always works.
8. On Domain India hosting
Shared hosting: the mail queue belongs to the server, so customers can't view or change it. If your mail is stuck or bouncing, check the sending limit (200 messages per hour per account on cPanel, 1,000 per day on DirectAdmin), read I can receive mail but I cannot send it, and open a ticket with the recipient address and the time you sent it.
Your own server: a Domain India VPS is self-managed with full root access. With the DirectAdmin panel option it runs Exim, so every command here works on it.
Frequently asked questions
How do I check the Exim mail queue?
Run exim -bpc for the number of queued messages and exim -bp for the full list. Pipe exim -bp into exiqsumm to see totals per recipient domain.
How do I delete frozen messages in Exim?
Run exiqgrep -z -i to list the IDs of frozen messages, check them, then pipe them to exim -Mrm with: exiqgrep -z -i | xargs -r exim -Mrm.
How do I delete all mail from one sender in the Exim queue?
First count the matches with exiqgrep -c -f followed by the sender address. If the list is right, delete them with exiqgrep -f followed by the address and -i, piped to xargs -r exim -Mrm.
Does exim -Mrm deliver the message before removing it?
No. exim -Mrm deletes the message without delivering it and without telling the sender. To deliver a message now, use exim -M with the message ID.
How do I force Exim to retry the whole queue?
exim -qf retries every message that is not frozen, and exim -qff includes frozen ones. Don't force a queue run while a remote provider is rate-limiting you; fix the cause first.
Can I manage the mail queue on shared hosting?
No. On shared hosting the provider manages the mail server and its queue. On Domain India shared hosting, open a support ticket with the recipient and the time you sent the message.
Ready to go further? Read Fixing the Exim 421 error for deliverability problems, or see VPS plans if you want your own mail server.
Send us the sender, the recipient and the time the message was sent, and we will check the mail queue and logs for you.
Open a support ticket