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 needful 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 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. 🙂

Syntax:

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

Where;
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.

Example:

[email protected]# 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

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

2 Responses

  1. ragul says:

    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 *