- List messages.
- Delete messages.
- Hold messages.
- Re-queue messages.
- Display the contents of messages.
- Flush the messages in the queue.
Listing Messages in the Postfix Queue
Postfix provides a tool called postqueue
. The command provided with the -p
switch will display an entry for each message in the queue. The output will include a column for the message ID, size, arrival time, send, and recipient addresses.
Messages that are currently in the active queue will display a asterisk to the right of the message ID.
If there is a message in the hold queue, it will display a exclamation point to the right of the message ID.
If a message is deferred, there will not be symbol / mark to the right of the message ID.
postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
5866DAC07F3 362 Sat Oct 12 15:53:56 trankin@tullyr.com
(connect to mail.tullyr.com[208.70.75.100]:25: Connection refused)
<trankin@tullyr.com>
Deleting Messages in the Postfix Queue
To delete messages from the Postfix queue, you can use the postsuper
command. The postsuper tool can be used to delete a single message, or all messages in the queue.
To delete a single message from the queue, provide the -d
switch followed by the message ID
.
postsuper -d 5866DAC07F3
When you want to delete all messages in the queue, you provide postsuper with the word ALL in all capitals instead of the message ID.
postsuper -d ALL
NOTE – Be careful when using the postsuper
command with the -d ALL
switch. This command will delete all messages in the queue immediately without prompting you for verification.
Holding Messages in the Postfix Queue
The Postfix hold queue provides a place for messages to be held indefinitely. If you move a message into the hold queue, it will not be delivered until you specifically remove it or move it back into the normal queue processing.
To place a message in the hold queue, you use the tool postsuper
with the -h
switch followed by message ID.
postsuper -h 5866DAC07F3
When you need to move a messae back into the normal queue for processing, you use the postsuper
command with the -H
switch followed by the message ID.
postsuper -H 5866DAC07F3
Re-queue Messages in the Postfix Queue
If you have messages that are incorrect based on a misconfigured Postfix installation, you may need to re-queue the messages via the postsuper
command. Some example of bad messages could be problems such as incorrect transport type, incorrect rewriting of an address, or an incorrect next hop.
After fixing the Postfix configuration, you can re-queue a single message or all messages. To requeue a message, you will use the postsuper
command with the -r
switch. When this command is run, it will update the incorrect information based on the new configuration.
To re-queue a single message you pass the message ID as in the example below.
postsuper -r 5866DAC07F3
If you need to re-queue all messages, you can pass the capital word ALL.
postsuper -r ALL
Displaying the Contents of Messages in the Postfix Queue
If you need to view the contents of a message in the queue, Postfix provides the postcat tool
for this. The postcat
tool will display the contents of a file when provided with the -q
switch followed by the message ID.
postcat -q 5866DAC07F3
Flushing Messages in the Postfix Queue
If you have messages in the queue that you would like to flush, you can use the postqueue
command with the -f
switch. Flushing the queue will cause Postfix to attempt to deliver all messages in the queue immediately.
postqueue -f
There are times when this is needed. However, it’s usually not a good idea to flush all of the messages in the queue. If you do this a lot, it can have an impact on the performance on your mail server. You should leave the queue management to the Postfix queue manager.
With Postfix, it’s possible to flush only those messages that are going to a specific domain. You can do this with the -s
switch provided by postqueue
. However, to do this the domain must be eligible for fast flush.
For a domain to be eligible for fast flush, it must be listed in the fast_flush_domains
parameter. In Postfix, the default value for the fast_flush_domains
includes all of the hosts that are listed in relay_domains
.
To add the site to the fast_flush_domains
you can append it to the line fast_flush_domains
as shown below:
fast_flush_domains = $relay_domains tullyrankin.com
Now if you want to flush mail that is destined for the domain you added to the fast_flush_domains
, you can use the postqueue
command with the -s
option as shown below:
postqueue -s tullyrankin.com