Mail Queue Management Exim

Managing emails can be cumbersome when you need to look into several things such as removing spam mails, Frozen mails, Bounce mails, Queue force rerun, among others.

Now, from our experience, we are sharing some commonly used commands below for managing Exim Servers:

To get the total number of mails in the queue

# exim -bpc

To list the mails in the queue

# exim -bp

Used to remove the message from queue with Exim Id : 1VcjOL-0002YV-8g

# exim -Mrm 1VcjOL-0002YV-8g

Displays the Header details of the particualr email

# exim -Mvh 1VcjOL-0002YV-8g

Displays the body of the particular email

# exim -Mvb 1VcjOL-0002YV-8g

Re-run the Mailq

# exim -q -v

Re-run the mailq even if the server is experiencing Load

# exim -qf -v

Gives the Email Id’s of the mails in the queue

# exiqgrep -i

To deliver mails forcefully

# exim -qff

Gives the Mail Id’s of the mails send from

# exiqgrep -i -f

To remove mails from

# exiqgrep -i -f | xargs exim -Mrm

To remove the mails in the queue completely

# exim -bp | awk ‘/^ *[0-9]+[mhd]/{print “exim -Mrm ” $3}’ | bash

One example we had was while managing the server for a client we had more than 200K mails in the mail queue and we had to remove mails from a particular email account. In such a scenario you can use the below script:

# exim -bpr | grep "" | awk '{ print $3 }' > mailids.txt
# for i in `cat mailids.txt` ; do exim -Mrm $i ;done

To remove the frozen mails

# exim -bpr | grep frozen | awk {‘print $3'} | xargs exim -Mrm


# exiqgrep -z -i | xargs exim -Mrm

Another useful command for removing all emails from queue matching specific patterns ( like email address , subject , etc )

#  exiqgrep -i  > /tmp/mailids ; for id in `cat  /tmp/mailids` ;do exim -Mvh $id  |  grep "pattern" && exim -Mrm $id;  done ;  rm -f /tmp/mailids

How these first-hand experiences we shared should have helped you in managing the email queue in Exim.

For further queries please do talk to our server helpdesk support experts for the best technical support on Server Management, web hosting, cPanel server management, server monitoring, and more.


Facebook Comments