Fighting with Exim Queues

Although I am fond of Sendmail, I have to admin that there are lot of other respectable MTAs that do a great job, are very very powerful and are far easier to install, configure and administer. Due to my numerous CPanel servers I usually have to work with Exim MTA and perform various operations on my mail queues. Here are some very useful commands for Exim MTA.

Queue Search

  • Count Message in Queue:
    exim -bpc
  • Queue overview:
    exim -bp | exiqsumm
  • Messages in queue, only msg-ids:
    exiqgrep -i
  • Search messages in queue, based on sender:
    exiqgrep -f [sender]@domain.tld
  • Search messages in queue, based on recipient:
    exiqgrep -r [sender]@domain.tld
  • Search messages in queue, based on age:
    exiqgrep -o 14400 (older than 4 hours)
    exiqgrep -y 14400 (younger than 4 hours)
  • Search messages in queue, in frozen state:
    exiqgrep -z
  • For the above command show just the msg-ids use the -i switch. For example:
    exiqgrep -i -o 14400

Queue Delivery

  • Dequeue all messages:
    exim -q -v
  • Dequeue all messages for local delivery:
    exim -ql -v
  • Dequeue all messages, force:
    exim -qff -v
  • Deliver a message, force:
    exim -M <message-id>
  • Freeze a message:
    exim -Mf <message-id>
  • Thaw a message:
    exim -Mt <message-id>

Queue Remove

  • Fail a message, force:
    exim -Mg <message-id>
  • Remove all frozen messages:
    exiqgrep -z -i | xargs exim -Mrm
  • Remove old messages, for example older than 4 hours:
    exiqgrep -o 14400 -i | xargs exim -Mrm
  • Remove messages matching sting in body (thanks to bradthemad):
    grep -lr 'string to match' /var/spool/exim/input/ | sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | xargs exim -Mrm

More info can be found on the official Exim documentation page and especially on Exim tools page.

Leave a Comment

Your email address will not be published.