habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

cPanel Custom Query Delete

1 min read

cPanel-Custom-Query-Delete Dovecot’s Search Query Format

Have you ever experienced flooding spam mail from internal to external? The email account in your cPanel broadcasts to unknown email address destination. The number of email queues can be tens or even hundreds of thousands. How to remove “undelivered” Backscatter mail, due to bounced email effects that enter the webmail mailbox? This simple article will explain how to easily delete custom query in cPanel.

Case: cPanel Mail Flooding from Internal to External address

cPanel WHM server flooding occured mostly because weak password. We can check mail queue with easy command exim.

exim -bpc
exim -bp

From the results of the above command, we can analyze which account source the flooding occurred.

Exim Delete Mail Queue via Command Line

Easy method exim delete mail queue via command line.

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

Or if we meet mail frozen, can execute this command.

exim -bp|grep '<>' |awk {'print $3'}|xargs exim -Mrm

cPanel Roundcube Delete Mail Undelivered.

After we successfully find and determine the source of the spam email, then open the webmail user.

mailbox receive undelivered - cPanel Custom Query Delete
Picture 1 – Webmail cPanel show Mail Delivery Deferred

In picture 1 above, showing us that webmail inbox full receive mail undelivered. We can delete it by selecting all on 1 full page.

But what if there are 1000s of pages? Of course this method is not effective.

Why Need Delete Email with Custom Query in Webmail

Remember, if we have thousands or even tens of thousands of inbox in webmail and happened a backscatter mail undelivered, we will have a headache choosing to delete one by one. Because it is mixed between legitimate email and backscatter email.
Need a custom query so that only matching query strings will be deleted.
Not all emails in webmail are deleted.

How to Custom Query Delete in cPanel

Open webmail, and than navigate to “Manage Disk Usage”

cPanel Custom Query Delete

Click “manage”, and select custom query.

We only want to delete emails that have the subject “Mail delivery deferred”.

Type subject "Mail delivery deferred" in custom query box. And delete permanently.

cPanel Custom Query Delete

For full documentation, please read Dovecot’s Search Query Format. May be it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it.


habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

2 Replies to “cPanel Custom Query Delete”

  1. Hi,

    Thanks, very useful for clearing out redundant emails.
    The Dovecot’s Search Query Format link needs updating to point to the new documentation location though 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox