How to purge postfix mail queue

To purge the Postfix mail queue, you can use the following commands:

Method 1: Purge all messages in the queue

  1. Connect to your Postfix server using SSH or a terminal.
  2. Run the following command to purge all messages in the queue:
    postsuper -d ALL

    This command will delete all messages in the queue, including those that are still being processed.

Method 2: Purge messages by status

  1. Connect to your Postfix server using SSH or a terminal.
  2. Run the following command to purge messages with a specific status:
    postsuper -d <status>

    Replace <status> with one of the following values:

For example, to purge all messages that are on hold, run:

postsuper -d hold

Method 3: Purge messages by message ID

  1. Connect to your Postfix server using SSH or a terminal.
  2. Run the following command to purge a specific message:
    postsuper -d <message_id>

    Replace <message_id> with the ID of the message you want to purge. You can find the message ID in the Postfix log files or by using the postcat command:

    postcat -q <message_id>

    Method 4: Purge messages using a cron job

If you want to purge the mail queue regularly, you can create a cron job to run the postsuper command at a specific interval. For example, to purge the mail queue every hour, add the following line to your crontab:

0 * * * * postfix postsuper -d ALL

This will run the postsuper command every hour to purge all messages in the queue.

Important notes: