How to delete mails from Exim mail queue

To print a list of the messages in the queue, enter:

# exim -bp

To remove a message from the queue, enter:

# exim -Mrm {message-id}

To remove all messages from the queue, enter:

# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash
suggested following clean command:
# exim -bp | exiqgrep -i | xargs exim -Mrm

Task: Delete Mail Linux Exim Server

To delete email for a particular user use shell pipes. By default the exim mail queue is located at /var/spool/exim/input directory. To delete email for a particular user called vivek@nixcraft.co.in, enter:
# exiqgrep -ir email@domain.com | xargs exim -Mrm
# exiqgrep -ir vivek@nixcraft.co.in | xargs exim -Mrm

Sometimes there can be so many frozen mails in the  Exim mail queue.

To know the number of frozen mails in the mail queue, you can use the following command

exim -bpr | grep frozen | wc -l 

In order to remove all frozen mails from the Exim mail  queue, use the following command

exim -bpr | grep frozen | awk {‘print $3’} | xargs exim -Mrm 

You can also use the command given below to delete all frozen mails

exiqgrep -z -i | xargs exim -Mrm

If you want to only delete frozen messages older than a day, you can try the following

exiqgrep -zi -o 86400

where you can change the value 86400 depending on the time frame you want to keep (1 day = 86400 seconds).

Similar Posts