[1] Removing Bad Mail
for i in `exiqgrep -i -f nobody`; do exim -Mrm $i; done >> Removes Nobody Mail
for i in `exiqgrep -i -o 259200`; do exim -Mrm $i; done >> Removes Mail Older than 3 Days
for i in `exiqgrep -i -f “^<>$”`; do exim -Mrm $i; done >> Removes Mail with Weird Characters (Spam)
[2] Delete Mail by a Domain
for i in `exiqgrep -i -f domain.com`; do exim -Mrm $i; done
[3] Delete Mail for a Domain
for i in `exiqgrep -i -r domain.com`; do exim -Mrm $i; done
[4] Remove Whole Mail Queue
for i in `exiqgrep -i -f `; do exim -Mrm $i; done
find /var/spool/exim/input -type f -exec rm -f {} +
exim -bp | awk ‘/^ *[0-9]+[mhd]/{print “exim -Mrm ” $3}’ | bash
[5] Run Mail Queue
runq -qqff&
http://webhosting.bigresource.com/SSH-tricks-in-exim-to-remove-email-queue-5qO05ybk.html
http://www.gnode.net/exim-queue-line-mismatch/
Here’s a quick fix when you are getting the following error. The 33d
and 1Lmb37-0007Pv-MX
parts will differ depending on which is the problematic message:
root@server [~]# exiqgrep -i -o 150000 Line mismatch: 33d 1Lmb37-0007Pv-MX (xxxx)
The problem originates from a message in the queue missing its -H
or -D
message part. Typically you can just issue an exim -Mrm <message-ID>
to remove the offending message. However, sometimes this can be problematic as there will be multiple such messages (usually when the queue is quite large). You can use the following pseudo-script to remove all messages in the queue from a specific day, e.g. the day that was indicated in the error above. Note that you will need to change the 33d
part in the line below to match that given by the error:
# exim -bpru | grep '33d' | awk '{print $3}'|xargs -n 1 -P 20 exim -Mrm
Depending on the size of your queue, this could take a bit of time. On a dual Xeon 5130 box with 440,000 messages in the queue this took over an hour to complete. Also, this particular queue had quite a few messages in it that were missing their message counterpart so I had to run this command a few times with different date search strings (the ’33d’ part).