Working with Exim and queue

Useful Exim commands

Here are some useful Exim commands. They're useful if you have an overloaded queue and need to clear it out, or find out why the messages are accumulating.

exim -M id      #Try to send the message with id id

exim -qf       #Tell Exim to process the entire queue again
exim -qff      #same as qf, but it will flush the frozen messages
exim -Mvl id    #view the message log for message id
exim -Mvh id    #view message id's headers
exim -Mvb id    #view message id's body
exim -Mrm id    #remove message id from the queue
exim -Mg id     #fail and send a bounce to the sender
exim -bp | exiqsumm    #Print summary of the messages in the queue
exiwhat        #show what Exim is doing right now
exim -bpc      #show number of messages in the queue
exim -bp       #print list of messages in the queue

The manual way to remove the entire queue is as follows

cd /var/spool
mv exim exim.old
mkdir -p exim/input
mkdir -p exim/msglog
mkdir -p exim/db
chown -R mail:mail exim

Then restart Exim.

Run Exim in debug mode in the foreground to test incoming SMTP connections:

exim -bd -d

Exim is going crazy, how to track down what it is doing?

If you have many Exim processes, the first place to check is Admin Level -> Mail Queue Administration .

Check for any patterns in the sender or recipient addresses.

Check the status of some of the messages to see why they're in the queue... if there is a common problem as to why they're in your queue (bottom textarea).

You can also get Exim to create a stats page for you:

cd /var/log/exim
eximstats mainlog > stats.txt
less stats.txt

Check it to see where most of the emails are headed, either outbound or local.

How to count how many smtp-auth sends were done by a particular login or IP

If you think someone is sending email using smtp-auth through your system, but need a quick way to count up each user/IP total, you can use the following script:



echo -n '' > $A
for m in `ls /var/log/exim/mainlog*`; do
       grep 'P=esmtpa A=login:' $m >> $A

#show Users
cat $A | cut -d= -f5 | cut -d: -f2 |cut -d\  -f1 | sort -u > $U

echo -n '' > $C
for u in `cat $U`; do
       echo "`grep -c $u $A` sent by $u" >> $C;

cat $C | sort -n

#now show IPs
cat $A | cut -d= -f3 | cut -d[ -f2 | cut -d] -f1 | sort -u > $I
echo -n '' > $C
for i in `cat $I`; do
       echo "`grep -c $i $A` sent by $i" >> $C;

cat $C | sort -n

rm -f $A $U $C $I

exit 0;

Save it to a file, chmod to 755, and run it.

Keep in mind that it will process /var/log/exim/mainlog*

If this is too slow, remove the * character so it's just /var/log/exim/mainlog, that is, if you don't need stats for that far back.

How to list all email accounts on the system

If you need to get a list of all created email accounts on your server, including domain pointers, you can use this basic script:

for d in `cat /etc/virtual/domains`; do
       #system account
       S=`grep "^${d}:" /etc/virtual/domainowners | cut -d: -f2 | awk '{print $1;}'`
       if [ "${S}" != "" ]; then
               echo "${S}@${d}";

       if [ ! -s /etc/virtual/$d/passwd ]; then

       for e in `cat /etc/virtual/$d/passwd | cut -d: -f1`; do
               echo "${e}@${d}";
exit 0;
Last Updated: