postfix

How to Flush the Postfix Queue?

Postfix is a very popular mailing server that is very commonly used with the different flavors of the Linux operating system. This mailing server maintains different queues for keeping different kinds of emails. These queues are collectively referred to as Mail Queue. However, at times, your mail queue gets so much overstuffed with junk emails that there is no more room left for any other important emails. Therefore, it is highly recommended to clear your mail queue well in time. Therefore, today we will discuss in detail the method of flushing Postfix queue on Ubuntu 20.04.

Method of Flushing Postfix Queue:

For flushing the Postfix queue in Ubuntu 20.04, you will need to perform the following steps:

  • In this method, we are going to flush the Postfix queue via terminal commands in Ubuntu 20.04. Therefore, we will press Ctrl+ T or right-click anywhere on the desktop and then choose the Terminal option from the menu that appears to launch the terminal. Alternatively, we can even click on the Activities tab present on the desktop and then type terminal in the respective search bar. Then click on the terminal search result to launch the terminal window, as shown in the image below:

  • Now before flushing the email queue, it is advisable to have a look at your Postfix queue to know what resides inside it so that you do not end up deleting any important emails. For doing that, type the following command in your terminal and then press the Enter key:
postqueue –p

As soon as this command executes successfully, you will be able to see all the emails that currently reside in your Postfix queue. This command is also shown in the following image:

  • Once you have the knowledge about the content of your postfix queue and you have ensured that there is no important stuff inside it, you can either flush it out entirely, or you can even delete the deferred emails only. For completely flushing out the Postfix queue, type the following command in your terminal and then press the Enter key:
sudo postsuper –d ALL

Here, the “sudo” keyword is used because this command requires root privileges to run. If you omit this keyword, you will not be allowed to proceed with the execution of this command. It is shown in the image below:

  • As soon as the execution of this command finishes, your Postfix queue will be entirely flushed out. To confirm if this has happened or not, type the following command in your terminal and then press the Enter key:
postqueue –p

If the postsuper command has been executed successfully, then running the command mentioned above will tell you that your mail queue is empty since you have flushed it out completely as shown in the following image:

  • However, if you only want to delete the deferred emails, i.e., the emails that have not been delivered to the recipient’s mailing server, then type the following command in your terminal followed by pressing the Enter key:
sudo postsuper –d ALL deferred

Again, this command also requires root privileges to run; therefore, you must not omit the “sudo” keyword with it. Running this command will only delete the deferred emails from your Postfix queue. This command is shown in the image below:

Conclusion:

By making use of the method described in this article, you can quickly get rid of all the emails from your Postfix queue and hence clear it out for making space for more emails in the future. This method is extremely simple and convenient to follow, and it only takes a few seconds to get your work done by following this super-efficient method.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.