3

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)

John
  • 53
  • 6

3 Answers3

3
exiqgrep -i -f [luser]@domain | xargs exim -Mrm
topdog
  • 3,520
  • 17
  • 13
2

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

James Green
  • 895
  • 1
  • 9
  • 23
1

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.

BillThor
  • 27,737
  • 3
  • 37
  • 69