The instinct when an Exim queue hits 80,000 messages is to flush it. That instinct usually deletes legitimate customer mail mixed in with the spam from the compromise. A safe cleanup separates the queue into three buckets — spam from the abuse, undeliverable bounces, and stuck legitimate mail — and acts on each independently. The whole operation takes longer than exim -bpc | xargs exim -Mrm but you keep your customers’ trust.
What’s happening
When something compromises an account or a script goes haywire, Exim accepts the messages, attempts delivery, and queues whatever defers. The queue grows fast: every message has a -D (data) and a -H (header) file in /var/spool/exim/input/. A 100K queue is a few gigabytes of disk and minutes of exim -bp listing time. Flushing wholesale is fast and unsafe. Triage first.
How to verify
Get the queue size and a breakdown:
exim -bpc
exim -bp | head -50
exim -bp | awk '{print $4}' | grep -v "^$" | sort | uniq -c | sort -rn | head
The last command groups by sender so you can see which user or domain is responsible for the bulk. Cross-check the top sender against the abuse account.
The fix
-
Identify the abuse source. Use the breakdown above. The compromised account is usually responsible for 70%+ of the queue. Lock it (suspend the cPanel user, change password, kill active sessions) before touching the queue, or you’ll re-fill it.
-
Delete the abuse traffic by sender. Targeted:
exiqgrep -i -f "compromised@example.com" | xargs exim -Mrmexiqgrepfinds messages matching a pattern;-Mrmremoves them. Confirm the count first by running without the pipe to-Mrm. -
Inspect bounces. Mail with sender
<>is bounce traffic. Most should be removed once the abuse is gone:exiqgrep -i -f '<>' | xargs exim -MrmRead a handful first to confirm they’re all bounces and not legitimate delivery status notifications.
-
For the remainder, force a queue run to flush the legitimate stuck mail:
exim -qff-qffretries every frozen message; combined with-q -vfor verbosity, you’ll see which destinations are actually accepting now. -
For mail stuck on dead domains, freeze and discard those messages specifically — don’t blanket-delete by age.
exim -bpwith a date filter helps surface the truly abandoned messages.
For environments where a queue spike is an incident and not a footnote, Stack Harbor builds the triage runbook into cPanel/WHM management so the next on-call doesn’t reinvent it.