Postfix queue tips

Want to count how many given email address apear in in postfix queue? Use this handy combination of grep, sed and awk to find out...


/usr/sbin/postqueue -c /etc/postfix-smtp -p |grep -P '^[0-9A-F]+' | sed 's/*//g' | awk '{print $7}' | grep 'email@address.com' | wc -l

Without sed also works. Sometimes grep -P is not avaiable and you get:

grep: Support for the -P option is not compiled into this --disable-perl-regexp binary

Use egrep instead to count the total number of emails in deffered queue:


/usr/sbin/postqueue -p | egrep '^[0-9A-F]+' | awk '{print $7}' | wc -l