How do I delete the pending email in the Exim queue?
You will first want to check the total count of emails in the queue to get a better understanding of how many emails you will be cleaning out with the following command:
After determining the total number of emails, the exiqgrep command can be used to filter these messages:
Filter all frozen emails:
exim -bp| exiqgrep -z
Filter all unfrozen emails:
exim -bp| exiqgrep -x
Filter by the sender:
exim -bp| exiqgrep -f firstname.lastname@example.org
The output of the above commands will look similar to what's below, with the time in queue, size, Exim message ID, sender, if the email is frozen or not, and the recipient.
19m 1.8K 1pcOAl-0004Ak-2w <email@example.com> *** frozen ***
After reviewing the emails you want to delete, you can just -i flag to return only the Exim message IDs and pipe the output into Exim to remove the email.
Please note these commands will remove ALL email from the mail queue that matches the filter, which may include legitimate emails. It is not possible to recover these emails once they have been deleted.
Delete all frozen emails:
exim -bp| exiqgrep -iz | xargs exim -Mrm
Delete all unfrozen emails:
exim -bp| exiqgrep -ix | xargs exim -Mrm
Delete all emails by the sender:
exim -bp| exiqgrep -if firstname.lastname@example.org | xargs exim -Mrm