Qmail Queue

Posted by Tully on Wed 27 October 2010

Today I wanted to check how many emails were in the queue for Qmail. I also wanted to display where all the outgoing emails were getting sent, and get a count of how many are going to that email address.

To complete this task, I put together a quick bash script that loops through the queued emails, greps the to field, and then sorts and counts the results.

Qmail Queue Stats

cat /dev/null > /tmp/emailTmp
for i in $(find /var/qmail/queue/mess -type f)
    cat $i | egrep -o 'To:.*[com,org,net]' | awk '{print $2}' >> /tmp/emailTmp
cat /tmp/emailTmp | sort | uniq -c | sort -n
rm -f /tmp/emailTmp