Question
How do I delete unwanted email without losing legitimate mail? The queue may be large and there are various reasons why those emails are in queue. It's best to determine that on a case by case basis.
Answer
It is best to be as granular as possible when removing email. If you see most of the email in the queue is from an address and also to an address, then it is best to use both the -f for From and -r for Recipient options. If the From address was sender@wantstosend.com, and the Recipient is recipient@doesnotwant.com then the following would remove emails that match that criteria:
exiqgrep -f sender@wantstosend.com -r recipient@doesnotwant.com -i | xargs exim -Mrm
If You're certain you want to remove all email From sender@wantstosend.com then the command would be:
exiqgrep -f sender@wantstosend.com -i | xargs exim -Mrm
If there are a number of bounce back emails that show the From address as <> then the following can be used to remove those emails:
exiqgrep -f "^<>$" -i | xargs exim -Mrm
One last option if you're certain you want to remove all frozen emails the following can be used:
exiqgrep -z -i | xargs exim -Mrm
Learn more
To learn more about...
- exiqgrep, see the Exim utilities documentation.
- exim -Mrm, see the Exim command line documentation (hint, use search on page in your browser for "Mrm" to find it).
- xargs, see the manual page.