Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
NickTheGreek

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

Recommended Posts

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.

The default Exim command output field with details are explained below:

The “exim -bp” command output:

 4d  2.3K 1X0Baa-0006iR-Ml <>
          fax@145.144-238-87.ripe.rewwwwwfs.net

70h   999 1X0RmS-0002Ue-Fe <info@hxxxxxer.com>
          email@example.com

In the above list, there are two mails in the mail queue. The queue field details are explained below:

1st field : Message’s age. (Eg: 4d : Four day)

2nd field : Size. (2.3k)

3rd field : Message ID (1X0Baa-0006iR-Ml)

4th field : sender. (info@hxxxxxer.com)

5th field/second line : recipient address. (email@example.com)

It’s really simple to find/sort email details for a particular user (Sender or Receiver) from the Exim mail queue. We have already discussed about the Exim mail server in different way. Here I am explaining different option to sort emails for a User.

How to check spamming on server which has Exim MTA?

Electronic spamming is the use of electronic messaging systems to send unsolicited messages (spam), especially advertising, as well as sending messages repeatedly on the same site.

It happens in many ways on a mail server. Spamming is one of the common and frequent problem in web hosting industry. Spamming can cause your server’s IPs blocked at different RBLs, if any accounts in your server sends multiple spam emails.

Method I :

Basic method with “exim” command.
We can sort the emails by using the exim command, see the examples below:

I : List all emails from a particular sender:

# exim -bp|grep "username"

Where “username” is the sender name.

Example:

root@server [~]# exim -bp|grep olne5
43h  3.6K 1WFLFH-0006uA-Gk <olne5@nothing.com>
43h  3.6K 1WFLOL-0000LX-97 <olne5@nothing.com>
43h  1.9K 1WFLQG-0000hv-5M <olne5@nothing.com>
43h  3.6K 1WFM7W-0001T5-7B <olne5@nothing.com>
42h  6.0K 1WFMEn-0002yJ-A8 <olne5@nothing.com>
42h  3.7K 1WFMGq-0003Sf-4T <olne5@nothing.com>
42h  3.5K 1WFMyn-0002yN-Tt <olne5@nothing.com>
------
------

Use “wc -l” to count total emails
Example:

root@server [~]# exim -bp|grep olne5|wc -l
191

How to remove ? Yes, that’s actually our discussion. You can remove all emails from that user using “awk” and “xargs “ options.
Syntax:

# exim -bp|grep "username"| awk {'print $3'}| xargs exim -Mrm

Example:

root@server [~]# exim -bp|grep olne5| awk {'print $3'}| xargs exim -Mrm

Sorry, I can’t illustrate the example here, because those emails are important for that user  .

II : List all emails to a particular address:

# exim -bp|grep "username"

Where “username” is the recipient address.
Note that, the recipient details is listed in the second line of “exim -bp” command’s output.

Example:

root@server [~]# exim -bp|grep ommdsdsd
44h  3.6K 1WFLFH-0006uA-Gk <olne5@nothing.com>
          ommdsdsdws@yahoo.com
44h  3.6K 1WFLOL-0000LX-97 <olne5@nothing.com>
          ommdsdsdws@yahoo.com
44h  1.9K 1WFLQG-0000hv-5M <olne5@nothing.com>
          ommdsdsdws@yahoo.com
43h  3.6K 1WFM7W-0001T5-7B <ommane5@cphost8.veeblehosting.com>
          ommdsdsdws@yahoo.com
------
------

You can use the “awk” & “xargs” commands to remove it from the queue.

Method II :

By using the command “exiqgrep”
The command “exiqgrep” has some useful switches to manage emails which are in the Exim mail queue. Before deleting mails with exiqgrep you must have a little knowledge in “exiqgrep”.

The smart switches of “EXIQGREP” command:

1, -f : to search the exim mail queue for emails from a particular user.
Syntax:

# exiqgrep -f user@domain

2, -r : to search the exim mail queue for emails to a particular address.
Syntax:

# exiqgrep -r user@domain

3, -i : Prints the message ID
You can use it in different manner, some examples are;

Print the message-id of the entire queue:

# exiqgrep -i

You can use it with -f and -r switches to get message ID of a particular sender or receiver.

# exiqgrep -i [-r | -f] ...

4, -o : Prints messages older than a particular time.
Example:

# exiqgrep -o 86400

Where time is specified in Seconds.

5, -y : Prints messages younger than a particular time.

6, -s : Prints messages with a particular size in bytes.
Example:

# exiqgrep -s "^3..$"

“^3$” –> 3bytes
“^3.$” –> 3-30bytes
“^3..$” –> 3-300bytes
“^3…$” –> 3-3000bytes
And so on..

7, -z : list all frozen mails.

8, -x : List all unfrozen mails.

9, -c : Counts the matches with all of the above searches.
Example:

root@server [~]# exiqgrep -c -s "^3...$"
114 matches out of 584 messages

Alright, Hope you got an idea about the usages of “exiqgrep”, Now it is very simple to manage emails for a particular user with the help of “exiqgrep”.

How to remove all emails from a particular user using exiqgrep?

Do follow this command:

# exiqgrep -i -f $user | xargs exim -Mrm

How to remove all emails to a particular user using exiqgrep?

Do follow this command:

# exiqgrep -i -r $user | xargs exim -Mrm

That’s it 
Please let me know your suggestions.

 

https://www.crybit.com/remove-users-emails-form-mail-queue/

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...