In this tutorial we will learn, how to delete mail queue in Postfix .To clear the mail queue in Postfix, we will use the command called postsuper . Abbreviation of postsuper is Postfix superintendent . postsuper command can only be run by super user of the system eg. root . Postsuper command is used for postfix mail queue related maintenance work.
To check the mail queue in system, we use mailq
command . It might be possible when you use mailq command,you may see long list of mails which are not delivered. Most of the mails have deferred status .
In this tutorial we will use postsuper command to delete/remove the mail queue in Postfix MTA .
First run the command mailq
command to check how many mails are in queue
To clear/remove the mail queue in postfix,read the below given scenarios
Scenario 1 : Remove particular mail queue id (on running mailq command,you will get mail queue id)
postsuper -d mail_queue_id
Scenario 2: Remove ALL mails from queue
postsuper -d ALL
Scenario 3: Remove only ALL deferred mails which are in queue
postsuper -d ALL deferred
i delete queue mails using the command “postsuper –d ALL deferred”, how i can recover those deleted emails ???
How do we receive the mails from gmail or outlook to linux box where postfix,mailx,dovecot installed. I am able to send the mails to outside of the network. but cannot receive the mails to linux users. Could you please help.
Hello sharad chhetri,
Thank you for the Reply.
It is a MAC OS X Server. It uses postfix.
The server is spammed and sending lots of emails. There are 20000 emails in the mail queue. I was trying to delete them by using above command. But it gives no output like : xx messages deleted.
Hello Tattwam,
Because of 20000 mail in queue resisting to run the command. I hope you are able to list mailq by using command
postqueue -p
. If yes, then you can achieve this by using one liner loop bash script.Before this I want to check are you able to remove single mail by using command
postsuper -d give-mailq-id
. Replace give-mailq-id with real mailq id which you got from commandpostqueue -p
.I also need sample output from command
postqueue -p
. So that I can give you one liner looping bash command.Regards
Sharad
Hello Sharad
Thank you for the reply.
First of all I am not able to delete any message by : postsuper -d give-mailq-id, That particular mail re-appears in mailq.
Output of postqueue -p is :
Mail system is down — accessing queue directly
Mail queue is empty
Output of sudo mailq is too much big.
Last line : — 136258 Kbytes in 16306 Requests.
Then I fired sudo postfix status which gave me output : the Postfix mail system is not running
(But surprisingly I am able to send and receive most emails).
I am little bit confused why I am getting this message even if I am able to send/receive most of emails.
If I start postfix by : sudo postfix start, I am not able to send/receive emails.
It would be great if you can provide remote support.
Hello Tattvam,
I suspect mail has been sent via some other MTA not by postifx. It could be sendmail or any other which is running on port 25(by default).
You can use these 3 commands to verify which MTA is runnning.
I do not have OSX system now a days but these are generic unix command and it should work.
Regards
Sharad
Good Information. I am having MAC OS X Server. I am not able to delete the mails from mail queue by using above commands. After using sudo postfix -d ALL, I am not getting any output.
Any help will be appreciated.
Hello Tattwam,
There are many packages which help to setup mail server. Can you provide the information which mail server have you setup in your system (is it postfix, sendmail,exim etc. ?)
Regards
Sharad