Home > Mail, Postfix > Postfix administration tips

Postfix administration tips

1) Queue count

postqueue  -p|awk 'NF==7 && $1 ~ /^[A-Z0-9a-z]/{print $1}'|wc -l

2) Top 10 senders

postqueue -p|awk 'NF==7{print $NF}'|sort|uniq -c|sort -nr|head

3) List out emails send by given email address,

read -p "Email: " EMAIL;postqueue -p|awk -v email=${EMAIL} '$NF ~ email{if(NF>6)print $0}'|head

4) Delete all emails send by given email address,

read -p "Email: " EMAIL; postqueue -p|awk -v email=${EMAIL} '$NF ~ email{if(NF>6){split($1,a,"*");system("postsuper -d "a[1]);}}'

5) Extract headers of all emails in queue to file “list.txt” along with the mail id at the top. This could be later used for performing various pattern analysis based on header.

queuelist=$(postqueue  -p|awk 'NF==7 && $1 ~ /^[A-Z0-9a-z]/{print $1}')
for i in $queuelist;do 
j=$(echo ${i}|tr -d '*')
echo -n "${j} " >> list.txt
postcat -q ${j} 2>/dev/null|sed -n '/^message_size:/,/^Content-/p' >> list.txt

6) Find out for which email id is MAILER-DAEMON bounces are coming. There is an option to remove the MAILER-DAEMON bounces for a specific email id as well. Useful while troubleshooting increased bounces in queue.


EMAIL="MAILER-DAEMON";postqueue -p|awk -v email=${EMAIL} '$NF ~ email{if(NF>6){split($1,a,"!");print a[1]}}' > /tmp/mailer-daemon.txt
for i in `cat /tmp/mailer-daemon.txt`;do  postcat -q $i |sed -nr 's/^recipient:\s(.*@.*)$/'${i}' \1/p'; done >> /tmp/mailer-daemon_details.txt
awk '{print $2}' /tmp/mailer-daemon_details.txt|sort|uniq -c|sort -nr|head
read -p "Email: " EMAIL;awk -v email=${EMAIL} '$2 ~ email{system("postsuper -d " $1)}' /tmp/mailer-daemon_details.txt 

7) Put email “on hold” queue so that no attempt is made to deliver it,

postsuper -h MSG_QUEUEID

8) Requeue the message with the named queue ID,

postsuper -r MSG_QUEUEID

9) Show postfix deferred queue message distribution in time based on sender domain,

qshape -s deferred


Categories: Mail, Postfix
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: