(Last Updated On: January 5, 2018)

Hello good people, here is a Postfix Commands Administration Cheat Sheet I made as a quick reference when administering Postfix. It contains most used postfix commands for troubleshooting problems. Postfix is one of the most popular open-source email relay servers out there, exim coming close to it.

Recently I covered:

Installing postfix3 on CentOS 7

and

How to Install cbpolicyd On CentOS 7

Postfix checking email queues.

To check current active  mail queue, use the command:

$ mailq

Get email accounts with high Postfix queues

$ mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n|tail

Using Postfix postsuper command

postsuper is Postfix superintendent. This is command does maintenance jobs on the Postfix queue. Use of the postsuper command is restricted to the superuser of the Mail server. By default, postsuper performs the operations requested with the -s, and -p command-line options on all Postfix queue directories – this includes the incoming, active and deferred directories with mail files and the bounce, defer, trace and flush directories with log files.

Command options:

-d queue_id –>  Delete one message with the named queue ID from the named mail queue(s)
(default: hold, incoming, active and deferred).

-h queue_id — > Put mail “on hold” so that no attempt is made to deliver it. Move one message
with the named queue ID from the named mail queue(s) – (default: incoming, active and deferred) to the hold queue.

-H queue_id –> Release mail that was put “on hold”. Move one message with the named queue ID
from the named mail queue(s) – (default: hold) to the deferred queue.

-r queue_id –> Requeue the message with the named queue ID from the named mail queue(s)- (default: hold, incoming, active and deferred).

Examples:

Postfix hold all deferred messages

# postsuper -h ALL deferred

Postfix remove all messages on hold

# postsuper -d ALL hold

This releases all mail that was put “on hold”

Beside hold, you can do same for incoming, active and deferred.

Postfix release all messages on HOLD.

 # postsuper -H ALL

Postfix dump all mails back to queue (Requeue)

# postsuper -r ALL

(default: hold, incoming, active and deferred)

Postfix purge old temporary files

# postsuper -p

Using Postfix postqueue command.

postqueue – This is a Postfix queue control tool. The postqueue command implements the Postfix user interface for queue management. It implements operations that are traditionally available via the sendmail command. postqueue command options:

-f  –> Flush the queue: attempt to deliver all queued mail.

-i queue_id –> Schedule immediate delivery of deferred mail with the specified queue ID.

-j  –> Produce a queue listing in JSON format, based on the output from the showq daemon

-p –> Produce a traditional sendmail-style queue listing. This option implements
the traditional mailq command, by contacting the Postfix showq daemon.The queue ID string is followed by an optional status character:

           *  –> The message is in the active queue, i.e. the message is selected for delivery.

          !  –> The message is in the hold queue, i.e. no further delivery attempt will be made until the mail is taken off hold.

Examples:

Flushing queue with postqueue:

$ postqueue -f

Print  postfix queue in sendmail-style:

$ postqueue -p

Postfix print queue in JSON format

$ postqueue -j

Have fun using Postfix Commands Administration Cheat Sheet, drop comments for any commands you often use when working with Postfix Relay servers. I’ll be happy to update this list with any new item.