Simple steps to count emails in Exim mail queue for a specific sender/receiver

In Exim MTA(Mail Transfer Agent) there are a lot of options/commands available to manage the Email queue simply.

Also, we can simply figure it out if there any spamming on that server which has Exim as MTA. We have already discussed a lot of command-line usages for Exim in my previous posts. Here I am looking for a new trick on Exim command to count total number of emails in the mail queue for a specific user(Sender or Recipient)

We can sort-it-out in different ways. Simply, by using the command “exiqgrep” and the associated switches. Also from the base command “exim -bp”.

This would be helpful to to analyse if there is any spamming from a particular account. More about spam check >> How to heck spamming on server which has Exim as MTA <<

Count emails for a user using “exiqgrep”

We have discussed the usage of the command exiqgrep for deleting emails from the mail queue.

Refer this for more details, Quick way to remove all emails from the mail queue and Quick way to remove all frozen emails from mail queue. Here I am listing the steps to count mail in the queue for users. We can use the switch “c” with the command exiqgrep for doing this.

Count mails for a sender.

exiqgrep -cf $user-name

c – To count.
f – For specifying sender name.


# exiqgrep -cf crybit
11 matches out of 17 messages

Count emails for a user using EXIM base command.

To count emails using the command “exim” is not much easy by comparing with the command “EXIQGREP”. Here is an example for that.

exim -bp|grep "<"|grep $user-name|wc -l


exim -bp|grep "<"|grep datesec|wc -l

Count mails for a recipient using “EXIQGREP’

Use the switch combination ‘cr’ instead of ‘cf’ with the command exiqgrep.


exiqgrep -cr $Recipient-address


exiqgrep -cr gayaxx10
11 matches out of 17 messages

Count mails for a recipient using “EXIM’ command.


exim -bp|grep $Recipient-address|wc -l


exim -bp|grep gayaxx10|wc -l

That’s it!! Hope these are helpful for you 🙂

Related links:
Check spamming on server having EXIM
Exim Log line flags
Important exim log file paths in WHM/cPanel & Directadmin


Exim command to remove emails from mail queue for a specific Sender/Receiver – The “exiqgrep” usage

In this post I am explaining the command usages for finding or sorting emails in Exim mail queue for particular sender or receiver.

We can sort it out in different ways, by using exim basic command and also by using the command “exiqgrep”. To sort mail queue for a sender or receiver, you must have the idea about the field in Exim command output. Then you can simply sort it out with the help of “awk” and other Linux basic commands.

Post navigation

Arunlal Ashok

DevOps Engineer. Linux lover. Traveller.
Always happy for an open discussion! Write to arun ((@)) crybit ((dot)) com.

Leave a Reply

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