петък, февруари 07, 2014

Postfix queue management

Read Postfix mail-logs
tail -f /var/log/mail.{err,log}

List all messages that are in the mailqueue
postqueue -p
or
mailq

Read an email from mail queue
postcat -qv  DA80E24A0A

Delete a message by message ID
postsuper -d MessageID
or Delete all messages in queue
postsuper -d  (d == delete)
or Delete only deferred messages
postsuper -d ALL deferred

Remove emails by recipient
mailq | tail +2 | awk ‘BEGIN { RS = “” }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($8 == “you@yourdomain.com” && $9 == “”) print $1 }‘ | tr -d ‘*!’ | postsuper -d -
replace you@yourdomain.com with the recipient email address.
Or more roughly but simple and powerful
mailq | grep badHostName | awk '{ print $1}' | postsuper -d -
Or more smaller
mailq | awk ‘/badHostName/ {print $1}’ | postsuper -d -

 Move all message from the incoming queue to the hold queue
postsuper -h ALL  (h == hold)
Move the messages back to the incoming queue
postsuper -r ALL   (r == requeue)

qshape command will show shape of active mail queue
qshape
Sample Outputs:
           T  5 10 20 40 80 160 320 640 1280 1280+
TOTAL  0  0  0  0  0  0   0   0   0    0     0
If a mail is deferred, it will be moved to deferred queue.

qshape deferred
Sample Output:
                      T  5 10 20 40 80 160 320 640 1280 1280+
        TOTAL  5  0  0  0  0  0   0   0   0    0     5
    gmail.com  4  0  0  0  0  0   0   0   0    0     4

Няма коментари: