How To Postfix Delete Mail From Queue?

Postfix Delete Mail From Queue

Postfix is a Mail Transfer Agent (MTA) with a set of programs such as Sendmail, Postqueue, Postsuper, etc. It routes the emails through the email servers to deliver it to the designated email account and also to receive emails. Reading the sender and recipient address, it chooses the right interface to perform the action.

There are two mail queues in Postfix, which are Pending and Differed. The pending queue has the emails that are not yet sent, and the deferred queue contains the emails that failed to send. Postfix tries to resend the emails in the deferred queue based on a default time interval, which can be modified as required. If you want to delete your emails from the Postfix queue, continue reading the below steps on postfix delete mail from queue.

Step-1: Check the mail queue

  • Step : 1 You need to know the emails present in the queue.
  • Step : 2 Open the Terminal on the server and enter the below command to view the mail queue and press Enter.
  • Step : 3 mailq

Step-2: Delete the email

Now, use the following commands to perform the deletion based on the scenario.

  • Step : 1 To delete all the emails in the queue, input the command and press Enter.
  • Step : 2 postsuper –d ALL (or)
  • Step : 3 postfix -f (or)
  • Step : 4 postfix flush
  • Step : 5 To delete all emails in the deferred queue, run the command on the system.
  • Step : 6 postsuper –d ALL deferred
  • Step : 7 To delete a specific email, use the following command. You can erase a particular email if you know its mail queue ID, which you should note from the mail queue. 
  • Step : 8 postsuper –d Mail_ID
  • Step : 9 To delete mail from a specific domain, mailq | grep domain_name |awk [ ‘print $1’ ] | xargs – I{} postsuper –d {} (or) ./ domain_name

By following the above mentioned steps to postfix delete mail from queue. Click the call button available on the screen.

mail settings net