Email & webmail

Manage the Exim mail queue in WHM (Mail Queue Manager, root)

Inspect, deliver and delete messages stuck in the Exim queue on your cPanel server with WHM Mail Queue Manager and command-line tools, and find the source of spam.

AdvancedWHM2 min read

On a cPanel & WHM server, outgoing and incoming mail waits in the Exim queue when it cannot be delivered right away. A few hundred deferred messages are normal; thousands usually mean a spam outbreak or a remote server rejecting your mail. WHM's Mail Queue Manager and a few Exim commands let you see what is there and clean it up.

Before you start

  • Root access to WHM (https://server-hostname:2087) and SSH.
  • On MdmHost shared and reseller hosting our team manages the queue; this guide is for your own server or VPS.

Check the queue size

exim -bpc

shows the number of messages. For a summary by domain:

exim -bp | exiqsumm | sort -n -k1 | tail -20

Use Mail Queue Manager in WHM

  1. Open WHM → Email → Mail Queue Manager.
  2. Filter by Sender, Recipient, Message ID or Subject, and by date.
  3. Click a message to see its headers, body and delivery log.
  4. Select messages and choose Deliver (try again now) or Delete. Deliver All and Delete All act on the whole filtered result.

Warning: Delete only after you are sure the messages are spam or undeliverable. Deleted mail is gone; senders are not notified.

Find the source of spam

  1. Open a few queued messages and read the headers. Look for:
    • X-Authenticated-Sender: a mailbox password was stolen.
    • X-PHP-Script or X-PHP-Originating-Script: a script on a website sends the mail; the header shows the account and file.
    • X-Get-Message-Sender-Via ... authenticated_id: the cPanel user responsible.
  2. Count senders in the queue:
    exim -bp | awk '/^ *[0-9]+[mhd]/{print $4}' | sort | uniq -c | sort -n | tail
  3. Stop the source: change the mailbox password, suspend outgoing mail for the account (WHM → Account Functions → Manage Account Suspension or the account's email settings), or disable the abused script.

Clean up from the command line

TaskCommand
Delete all frozen messagesexiqgrep -z -i | xargs exim -Mrm
Delete messages from one senderexiqgrep -i -f spammer@example.com | xargs exim -Mrm
Delete messages to one domainexiqgrep -i -r baddomain.tld | xargs exim -Mrm
Delete messages older than 1 dayexiqgrep -o 86400 -i | xargs exim -Mrm
Retry delivery of the whole queueexim -qff
View a message's logexim -Mvl MESSAGE-ID

After a spam incident

  • Check whether the server IP is blocklisted and request delisting once the source is fixed.
  • Limit hourly sending per domain in WHM → Server Configuration → Tweak Settings → Mail (Max hourly emails per domain) and per package.
  • Review SPF, DKIM and DMARC for affected domains.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.