
postqueue Command in Linux
The postqueue command in Linux is used to manage the Postfix mail queue. It allows listing and flushing the mail queue. Unlike postsuper, which requires super-user privileges for actions like deleting messages, postqueue operates under normal user permissions. It interacts with the queue and helps troubleshoot or manage pending emails efficiently.
Table of Contents
Here is a comprehensive guide to the options available with the postqueue command â
Syntax of postqueue Command
The syntax of the postqueue command in Linux is as follows −
postqueue [options]
The [options] field specifies various options for managing the mail queue, such as flushing the queue or displaying its contents.
postqueue Command Options
The options of the postqueue command in Linux are listed below −
Option | Description |
---|---|
-c config_dir | Specifies the main.cf file location in a custom directory instead of the default. Refer to MAIL_CONFIG environment setting. |
-f | Flushing the queue attempts to deliver all queued mail, similar to sendmail -q. Frequent flushing of undeliverable mail may degrade overall delivery performance. |
-i queue_id | Schedules immediate delivery for deferred mail with the specified queue ID, similar to sendmail -qI. Available in Postfix 2.4 and later. |
-j | Produces a queue listing in JSON LINES format from the showq daemon. Available in Postfix 3.1 and later. |
-p | Generates a traditional mailq queue listing, showing message details (size, sender, recipient, etc.). It contacts the Postfix showq daemon. |
-s site | Schedules immediate delivery of all mail for the specified site, using the fast flush service. The site must be a valid RFC 5321 address literal. |
-v | Enables verbose logging for debugging. Multiple -v options increase verbosity. Available for super-user as of Postfix 2.3. |
Examples of postqueue Command in Linux
This section explores how to use the Postfix postqueue command in Linux with examples −
Displaying the Mail Queue
To display the mail queue, use the -p option with the postqueue command −
postqueue -p

The above command prints the current mail queue, including details like the queue ID, sender, recipient, size, and status as shown in the above output image.
Displaying the Mail Queue in JSON Format
To display the mail queue in the JSON format, use the -j option −
postqueue -j

Flushing the Mail Queue
To flush the mail queue, use the -f option. The following command attempts to deliver all queued mail by flushing the queue −
postqueue -f
Getting Verbose Output
To get the detailed output, use the -v option −
postqueue -v -f
To increase the verbosity level, use the -v multiple times −
postqueue -v -v -f

Flushing by Specific Message ID
To flush an email by its mail ID, use the -i option with the mail ID. The mail ID can be obtained using the postqueue -p command −
postqueue -i 73EF1163306
The above command schedules the immediate delivery of a specific message in the queue using its queue ID.
Flushing by Specific Site ID
The site ID (domain/IP) is used to flush messages specifically destined for a particular site or mail server instead of flushing the entire mail queue. To flush mail queued for a specific site such as a domain or IP address, use the -s option −
postqueue -s 192.168.1.1
The IP address or domain should be enclosed in square brackets when using an address literal, such as for an IPv6 address.
Conclusion
The postqueue command in Linux is an essential tool for managing the Postfix mail queue. It offers functionality for listing and flushing emails in the queue, without requiring superuser privileges. Various options are available to customize its operation, such as displaying the queue in different formats or flushing specific messages or sites.
In this tutorial, we covered the postqueue command, its syntax, options, and usage in Linux with examples.