Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)

share|improve this question

3 Answers 3

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

share|improve this answer
exiqgrep -i -f [luser]@domain | xargs exim -Mrm
share|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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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