This post lists some useful Postfix commands which will help you to troubleshoot Postfix email issues. Please check the Postfix commands below.
View the postfix version
postconf mail_version
Mail queue:
mailq
To get the number of emails in the queue:
mailq | wc -l
To list mail queue with Email IDs
postqueue -p
To process the queue:
postqueue -f
To remove all mail from the queue :
postsuper -d ALL
To remove all mails in the deferred queue :
postsuper -d ALL deferred
To remove specific mail from queue:
postsuper -d MAIL_ID
To view the mail content :
postcat -q MAIL_ID
To sort queued mails:
mailq | awk '/^[0-9,A-F]/ {print $7}' | sort | uniq -c | sort -n
To remove all mails sent by [email protected] from the queue:
mailq| grep '^[A-Z0-9]'| grep [email protected] |cut -f1 -d' ' |tr -d \*|postsuper -d -
To suspend all deliveries of emails in the queue:
postsuper -h ALL
To unsuspend the deliveries of emails in the queue:
postsuper -H ALL
To restart Posfix
postfix reload
Check the postfix installation:
postfix check
To show default postfix values:
postconf -d
To show non default postfix values:
postconf -n
To see the mails in a tree structure:
qshape
That’s it!