Postfix Useful Commands

To Check Postfix Queue
#mailq

To Check Sasl Auth
#tail -f /var/log/messages|grep sasl

To Check Posfix Logs
#tail -f /var/log/maillog|grep postfix

List of domains that are being deferred
#qshape-maia -s  deferred

Checking Specific Mail From Queue
---------------------------------------
To view the full mails
#postcat -q D5EB71AEA45
If you an error postcat: fatal: open queue file D5EB71AEA45: No such file or directory, Then it means mail has been delivered or removed using postsuper

If you want to remove specific mail from queue
#postsuper -d  D5EB71AEA45

Sorting Queued Mails By From Address:
# mailq | awk '/^[0-9,A-F]/ {print $7}' | sort | uniq -c | sort -n

Removing Mails Based On Sender Address
# mailq| grep '^[A-Z0-9]'|grep peggysj@msn.com|cut -f1 -d' ' |tr -d \*|postsuper -d -

or, if you have put the queue on hold, use
# mailq | awk '/^[0-9,A-F].*capitalone@mailade.com/ {print $1}' | cut -d '!' -f 1 | postsuper -d -
to remove all mails being sent using the From address “capitalone@mailade.com”.


if you want to remove all mails sent by the domain msn.com from the queue
#mailq| grep '^[A-Z0-9]'|grep @msn.com|cut -f1 -d' ' |tr -d \*|postsuper -d -

No comments: