How to sort and count emails in mail queue with mail senders’ name – Exim command

We already discussed the same on one topic to find-out the spamming on cPanel server with Exim.

Here I am discussing some quick ways to list spam emails count with corresponding email senders’ name.

It’s very useful in some situations to find out the exact account which is involving in spamming activity.

Here, we need to use different Linux commands with pipe option to list emails count with user-name.

How/Command to find out the spam mailing script’s location – Exim mail server?

The Exim mail server has a lot of options/commands to find out the details of spammers easily and i details from the command line itself. Please refer to the blog post “Spam Check” to get more ideas about Exim spam trouble shooting.

We can find out the mail queue details, spam mail sender details, spam mail counts etc from the link I mentioned above. As a Linux SysAdmin, that should be helpful for your daily tasks.

Here is a script/piped-command to find out the spam mailing script’s location/folder in the server. It would be more helpful for us to identify the spam mail sending script and we can null-route it easily to mitigate spamming activity on server. Read More…

How to list email count with sender information from the Exim mail queue ?

We can use the base command “exim -bp” to do our concern. The output of the command “exim -bp” contains the user details, both sender and receiver email address. So, we can use it for our purpose. 🙂


exim -bp|grep "<"|awk {'print $4'}|cut -d"<" -f2|cut -d">" -f1|sort -n|uniq -c|sort -nr


exim -bp : Is the base command to list all email in the mail queue with its details.

grep “<” : To grep out the Sender address line only.

awk {‘print $4’} : Output only the sender name section.

cut -d”<” -f2|cut -d”>” -f1 : To crop ‘<‘ and ‘>‘ 🙂

sort -n|uniq -c|sort -nr : To re-arrange and count.


root@server# exim -bp|grep "<"|awk {'print $4'}|cut -d"<" -f2|cut -d">" -f1|sort -n|uniq -c|sort -nr
     15 [email protected]
     10 [email protected]
      8 [email protected]
      5 [email protected]
      3 [email protected]
      3 [email protected]
      2 [email protected]
      2 [email protected]

In this example, 15 emails are in the Exim mail queue for the account ‘[email protected]’ and 10 for the user ‘[email protected]’ and so on.

To count all emails from that user, you may use the exiqgrep command with -f switch.

exiqgrep -f sendername|grep "<"|wc -l

That’s it!

Related Links:
Command to find out the spam mailing script’s location
Remove all frozen emails from mail queue
Remove emails from mail queue for a specific Sender/Receiver
Check spamming on server having EXIM

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

2 thoughts on “How to sort and count emails in mail queue with mail senders’ name – Exim command

  1. Hi!

    How to get a particular domain’s Inbound & Outbound Email Counts? I’m using VPS (LINUX). Your website is really awesome. I’m having 50+ domain in my WHM and sometimes, the daily SMTP limit has reached. And I want to know the things below..
    1) Domain wise Mail Inward & Sent report
    2) Domain wise spam mails report

    Can u help me.

    Thanks in Advance

Leave a Reply

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