Insights

Exim Queue Full of Frozen Messages? Read the Headers Before Deleting Them

November 7, 2026
0:00
When exim -bpc returns a number far bigger than usual and most of the queue is marked frozen, the tempting move is to wipe the frozen messages and close the ticket. The queue looks clean afterward, but if a compromised mailbox or a hacked script caused the pileup, it keeps sending. The queue refills, and by then the server's IP may already be on a blocklist. Frozen messages are evidence. Read a few before you delete any. This walkthrough follows the shape of a post-mortem: impact, investigation, the moment the cause becomes clear, short-term containment, and the longer fix. It describes a common pattern on shared hosting and mail VPS servers, not a specific incident.
Customers rarely report a frozen queue directly. They report side effects: mail going out slowly, legitimate messages landing in spam at remote providers, or bounce notices saying the server's IP is listed somewhere. On the server, the queue count climbs and listing the queue shows many entries tagged *** frozen ***. A frozen message is one Exim has stopped trying to deliver. Normal deferred mail stays in the queue and gets retried on a schedule. Frozen mail sits until an admin thaws it, removes it, or a timeout setting clears it. The most common reason Exim freezes a message is a bounce it cannot deliver. A bounce (a delivery status notification) goes to the original envelope sender, the address used in the SMTP MAIL FROM command, which can differ from the visible From header. If that address does not exist or rejects mail, Exim has nowhere left to send the failure report, so it freezes it. That detail matters. A big pile of frozen bounces usually means a lot of mail recently went out with sender addresses that cannot receive replies. Legitimate mail rarely does that. Spam with forged senders does it constantly.
The first step is getting a feel for the size and makeup of the queue without changing anything. All of these commands are read-only:
BASH
# Total messages in the queue
exim -bpc

# IDs of frozen messages only (-z = frozen, -i = print IDs only)
exiqgrep -z -i | head -n 20

# Headers of one message, including Exim's own envelope data
exim -Mvh 'MESSAGE_ID'

# Body of the same message (for a bounce, this includes the original mail)
exim -Mvb 'MESSAGE_ID'

# Full log history of that message ID
exigrep 'MESSAGE_ID' /var/log/exim_mainlog
The main log path depends on the setup. cPanel servers use /var/log/exim_mainlog, while Debian and Ubuntu's exim4 packages typically log to /var/log/exim4/mainlog. Open several frozen messages at random rather than just the first one. You are looking for a pattern, and one message can mislead you. In exim -Mvh output, the top lines are Exim's spool data, not normal mail headers. Near the start you will see the envelope sender in angle brackets. Further down are fields such as the sending host address and, when the message came in over authenticated SMTP, the authenticated identity. After that come the ordinary headers: From, To, Subject, Received. The main log adds the timeline. Each message ID has an arrival line marked <=, delivery lines marked =>, permanent failures marked **, and deferrals marked ==. For a frozen bounce, exigrep usually shows the bounce being generated, the attempt to deliver it failing, and a Frozen line.
Once you read a handful of messages, most queues fall into one of two groups. The first group is ordinary undeliverable bounces. The envelope sender is empty, shown as <>, which is how bounces are marked so they never generate bounces of their own. The recipient is some external address. Read the body with exim -Mvb and you will see the original message that failed. If those originals are a scattered mix of normal customer mail to dead addresses, this is routine noise. It is untidy but not an emergency. The second group looks different. Either the frozen bounces all point back to the same kind of original message (similar subjects, unrelated recipients, sender addresses at domains you don't host), or the queue also holds many non-bounce messages from one local account. Here the arrival lines in the main log give the cause away.
TEXT
Illustrative output format (placeholders, not a real log):

DATE TIME 1aBcDe-0001Xy-Z9 <= [email protected] H=(client) [203.0.113.10] P=esmtpsa A=dovecot_login:[email protected] S=2048
DATE TIME 1aBcDf-0002Ab-Q1 <= [email protected] U=cpuser P=local S=1536
The first line shows mail submitted over authenticated SMTP. P=esmtpsa means the client logged in, and the A= field names the login that was used. On cPanel servers this field comes from the authenticator config, so the name can differ elsewhere. If that login is sending to hundreds of unrelated recipients from IPs the customer doesn't recognize, the mailbox password has almost certainly leaked. The second line shows local submission, which typically means a script on the server called the mail binary through PHP mail() or a similar function. U= is the system user that ran it. If the envelope sender is a forged address at a domain you don't host, every remote rejection creates a bounce to that fake address, and every one of those bounces freezes. This is how a hacked WordPress plugin or an uploaded mailer script fills a queue with frozen messages that look harmless at first glance. The headers often narrow it further. cPanel's Exim config adds headers such as X-Get-Message-Sender-Via and X-Authenticated-Sender, and if PHP's mail.add_x_header is enabled, X-PHP-Originating-Script names the script and the user ID that ran it. Depending on log settings, a cwd= field on the arrival line can also show the directory the script ran from. This is also the most common misread at the support desk. Someone sees thousands of bounces, assumes the customer has a bad mailing list, and deletes them. The bounces were never the problem. They were the server's own spam echoing back.
Order matters here. Clear the queue first and you destroy the evidence while the source keeps running.
  1. Stop the source. For a compromised mailbox, change its password and end any active sessions. For a script, find the file from the headers or cwd= path, then disable or remove it, and check for other files dropped next to it.
  2. If you can't find the source right away, block outgoing mail for that one account. On cPanel and WHM there are per-account controls for this; where they live depends on the version. On other setups it usually means an Exim ACL or rate-limit rule.
  3. Save a few sample message IDs and their exigrep output somewhere outside the spool. That is your record for the customer and for any blocklist delisting request.
  4. Only then remove the junk, and target it instead of clearing everything.
Warning: exim -Mrm deletes messages permanently. There is no undo. Preview the list first, and filter by sender so legitimate frozen mail from other accounts survives.
BASH
# Preview: frozen messages from one sender (regex match on envelope sender)
exiqgrep -z -i -f 'user@customer-domain\.example'

# After checking the list above, remove only those messages
exiqgrep -z -i -f 'user@customer-domain\.example' | xargs -r exim -Mrm
For frozen bounces with a null sender, -f '^<>$' matches the empty envelope sender. Still preview before you pipe into -Mrm. Thawing (exim -Mt) makes sense only for messages you have confirmed are legitimate and whose original problem is fixed. Thawing spam bounces just makes Exim retry deliveries that will fail again. After cleanup, check the server's sending IP against the major blocklists and watch the queue count for a while. If it starts climbing again, the source is still active.
The deeper problem in this pattern is rarely the single leaked password. It's that the queue filled up quietly and nobody noticed until remote servers complained. A few changes help. Set limits on frozen mail. Exim's timeout_frozen_after removes frozen messages after a set time, and ignore_bounce_errors_after controls how long undeliverable bounces are kept. Check your current values with exim -bP timeout_frozen_after ignore_bounce_errors_after. Defaults vary, so confirm against your version's documentation. Be aware that an aggressive timeout cleans up the evidence for you, so pair it with monitoring. Monitor the queue count and the frozen count, not just whether Exim is running. A simple alert when the frozen count moves well above its normal baseline catches most compromises early. What "normal" means depends on the server, so measure it first. Cap outbound volume per account or per domain. Hourly send limits mean a compromised mailbox does limited damage before someone looks. Pair them with alerts so a customer who hits the limit gets a real explanation instead of a silent delay. Tighten local submission. Requiring scripts to send through authenticated SMTP instead of PHP mail() makes every message traceable to a login. Where that isn't practical, enabling mail.add_x_header at least records which script sent what. The practical takeaway is short. When the queue fills with frozen mail, open five or ten messages with exim -Mvh and exigrep before touching -Mrm. A null sender with mixed, normal-looking originals is routine cleanup. Forged senders, one login sending to strangers, or one system user pushing mail from a script means an active compromise. Contain that first, keep a few samples, then delete selectively.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.