How to empty mail queue on CentOS Linux system ?

How to empty mail queue on CentOS Linux system ?

Due to spamming, spoofing and other malpractice email queue become loaded with thousand of unwanted emails. It will slow down your server performance and mainly affect your exim to deliver emails.
It's not quite easy to sort out the genuine emails from these bulk spam mails as it is like finding needle in a haystack. The easiest and simplest way to overcome this is to flush the mail queue from exim.

First, we will learn how to list mail queue:

1). To List mail queue you can use this command :
-----
# exim -bp
-----

2). List all emails from a particular user :
-----
# exim -bp|grep username --Syntax
# exim -bp|grep hoststud --Example

-----

3). To count total number of emails from a particular user, you can use this command :
-----
# exim -bp|grep username|wc -l --Syntax
# exim -bp|grep hoststud|wc -l --Example

-----

4). To count total number of emails in exim mail queue, you can use this command :
-----
# exim -bpc
-----

Now, to remove emails from queue you can use below given commands.

5). To remove a particular email from queue :
-----
# exim -mrm {message-id}
-----

6). To remove mails for a particular user :
-----
# exim -bp|grep username| awk {'print $3'}| xargs exim -Mrm --Syntax
# exim -bp|grep hoststud| awk {'print $3'}| xargs exim -Mrm --Example

-----

7). To empty exim mail queue completly :
-----
# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash
# exim -bp | exiqgrep -i | xargs exim -Mrm
-- For CentOS
-----
Author
bhawanisingh
Views
3,330
First release
Last update
Rating
0.00 star(s) 0 ratings
Top