How to Delete Pending Emails in the Exim Queue

To delete pending emails in the Exim queue, follow these steps:


Step 1: Check Total Email Count in the Queue

exim -bpc

This command shows how many messages are currently in the queue.


Step 2: Filter Emails Based on Requirements

Filter All Frozen Emails:

exim -bp | exiqgrep -z

Filter All Unfrozen Emails:

exim -bp | exiqgrep -x

Filter by Sender:

exim -bp | exiqgrep -f [email protected]

Step 3: Review the Emails Before Deleting

The output will display:

  • Time in queue

  • Message size

  • Exim message ID

  • Sender email

  • Whether the message is frozen

  • Recipient email


Step 4: Delete Selected Emails

Warning: These actions are irreversible. Deleted emails cannot be recovered.

Delete All Frozen Emails:

exiqgrep -z -i | xargs -r exim -Mrm

Delete All Unfrozen Emails:

exiqgrep -x -i | xargs -r exim -Mrm

Delete All Emails by a Specific Sender:

exiqgrep -f [email protected] -i | xargs -r exim -Mrm

Make sure to use the correct sender email and double-check the filtered list before running deletion commands.


Forcefully Remove All Emails from the Exim Queue (Including Locked or Stuck Messages)

If you want to remove all emails in the queue regardless of status, use the following:

exim -bp | awk '{print $3}' | xargs -r exim -Mrm

Explanation:

  • exim -bp: Lists all queued messages.

  • awk '{print $3}': Extracts message IDs.

  • xargs -r exim -Mrm: Removes all identified messages.


If Messages Are Locked and Cannot Be Deleted Normally

Stop Exim and manually clear the spool directories:

service exim stop
rm -rf /var/spool/exim/input/*
rm -rf /var/spool/exim/msglog/*
service exim start

Clear Exim Retry Database (Optional)

Remove retry data for stuck delivery attempts:

rm -f /var/spool/exim/db/retry

Alternative Method: Remove Emails via WHM Interface

  1. Log in to WHM.

  2. Go to Email > Mail Queue Manager.

  3. Use the "Delete all messages in queue" option or manually remove selected entries.


Note: Always verify messages before deletion to avoid removing legitimate emails.

  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

Domain names are not showing in WHM

We were unable to see any domains listed under WHM -> List Accounts. However, we can see the...

How to Start/Stop or Restart Apache server

Apache is the HTTP server that is freely available over the internet. It is a kind of software or...

How to install Attracta SEO Tools plugin

RequirementscPanel/WHM needs to be installed on your server. Step 1: SSH into your server and go...

How to Install CpCleaner in cPanel through SSH?

Installation Run the following shell commands as root via SSH: wget -O cpc-1.0.3.tar...

How to Secure a cPanel/WHM Web Server

Here are a few basic steps that you should keep in mind for keeping a server secure. 1) Strong...