Sunday, August 18, 2019

Manage the postfix mailqueue with postsuper, postqueue and mailq

Postfix provides with postsuper, postqueue and mailq some  shell utilitys to manage the mailqueue.

Here are some examples for common tasks:-

I found this on this URL :-

Its a very good article, Thanks to faqforge.com

Some more useful commands:-


List All Emails :-
To list all mail of queue, use one of the following command
# postqueue -p
 Flush All Emails :- 
To delete or flush all emails from Postfix mail queue using the following command.
# postsuper -d ALL
 Flush Deferred Mails Only :-
You can only delete all deferred emails only from mail queue. Use the following command to delete deferred emails from the queue.
# postsuper -d ALL deferred
Remove Specific Email :-
If you want to remove any specific email. Use the following command to remove specific emails only. First search the ID of that email like below command
# postqueue -p | grep "email@xyz.com"
you will get result
527EF61F7A3   251145 Tue Aug 13 18:13:34  email@xyz.com
 
To Read email from this mail_id
   # postcat -q 527EF61F7A3 (your mail id)
 
Now delete the mail from mail queue with id 527EF61F7A3
# postsuper -d 527EF61F7A3

 To resend all emails:

 # postsuper -r ALL && postqueue -f

Remove messages from specific domain :- 

mailq | grep yourDomain.com | awk {'print $1'} | xargs -I{} postsuper -d {}


0 comments: