PHP script to monitor exim mail queue

When you run exim mail server, it is good to keep an eye on number of emails in mail queue. here is a PHP script that will check number of emails in queue, if it exceed pre-set number, it will email you.

Create file

Add following content.

In this case, if mails in queue exceeded 100, you get email.

You can change 100 to whatever number you need.

Replace [email protected] with your email address.

Set script to run every 10 minutes using cronjob

Cpanel Server Block Incoming SPF Failed Mails

One of the customer email account as getting too much incoming emails from [email protected]

First i tried to block the sender IP, but they are using too many IP.

To stop this incoming email, i edited


Add below

Restart exim

Now watch the mail log with


exiqgrep allows you to search exim mail queue.

To search for a particular recipients, run

To search for all emails from a particular email account, use

You can use -i option to list only message id. This is useful when you need to delete mails from a particular account.

To delete all email sent from a particular email account, run