I have an exim queue now of over 1000 e-mails and I want to run the queue and delete all the e-mails that are going to invalid e-mails(ones that no longer exist)
If the messages are in the queue and frozen, the below SHOULD work -- however I have not tested it and take no responsibility if it instead becomes sentient and eats your mailserver
for i in `mailq | grep "\*\*\* frozen \*\*\*" | cut -f 3 -d " "` ; do exim -Mrm $i ; done
Change the grep pattern as required if you need to hit non-frozen messages (this is easiest if you can be confident you can nuke everything in the queue, and be sure to run as a user who can run exim -Mrm and mailq usefully -- you may need to insert
Also, there is almost certainly a cleaner way to do this using xargs rather than the
for built-in and backticks. Hopefully someone will be along shortly with that :-)
Scan the files in
/var/spool/exim4/msglog for the invalid addresses.
You can mark an address as delivered with a command like (use the invalid address)
cd /var/spool/exim4/msglog; for msg in $(grep -l address); do exim4 -Mmd $msg address.
You can clear the messages with the command
cd /var/spool/exim4/msglog; exim4 -M *. This will try to deliver all messages in the queue.
You can block incoming messages to old addresses using an alias in
address : :fail: No longer here
man exim4 and
man aliases for more information.