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)

exiqgrep -i -f [luser]@domain | xargs exim -Mrm
| improve this answer | |

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 sudo before mailq and exim -Mrm...

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 :-)

| improve this answer | |

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 /etc/aliases like:

address : :fail: No longer here

See man exim4 and man aliases for more information.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.