Thursday 31 July 2014

Postfix commands

View the postfix version :
#  postconf  mail_version
mail_version = 2.3.3
Check the postfix installation :
#  postfix check
Show default postfix values :
#  postconf -d
To show non default postfix values :
#  postconf -n
To restart postfix mail server  :
# postfix reload
Flush the mail queue :
#  postfix  flush
Or you can use:
#  postfix  -f
To see mail queue :
#  mailq
( in send mail sendmail -bp )
#  mailq | wc -l
(will give the total no of mails in queue )
To remove all mail from the queue :
#  postsuper -d ALL
To remove all mails in the deferred queue :
#  postsuper -d ALL deferred
To see the mails in a tree structure :
#  qshape
View the mail content :
#  postcat -q  AFD4A228 37C
You will get the above id from mailq . Or you can view the mails from postfix mail spool. Usually postfix will store the mails in /var/spool/postfix/active/ from this location also you can view the mails .  We can change the queue directory from the postfix conf.
Sort by from address :
#  mailq | awk ‘/^[0-9,A-F]/ {print $7}’ | sort | uniq -c | sort -n
To remove all mails sent by user@adminlogs.info from the queue :
#  mailq| grep ‘^[A-Z0-9]‘|grep user@adminlogs.info|cut -f1 -d’ ‘ |tr -d \*|postsuper -d -
To remove all mails being sent using the From address “user@adminlogs.info” :
#  mailq | awk ‘/^[0-9,A-F].*user@adminlogs.info / {print $1}’ | cut -d ‘!’ -f 1 | postsuper -d -
To remove all mails sent by the domain adminlogs.info from the queue :
#  mailq| grep ‘^[A-Z0-9]‘|grep @adminlogs.info|cut -f1 -d’ ‘ |tr -d \*|postsuper -d -

No comments:

Post a Comment