How to Remove the Postfix Mail Queue

Share this Article :

Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers an email. Under Postfix MTA, there are basic command to empty or remove Postfix Mail Queue. In the case of the postfix MTA server suddenly offline or postfix service not respond, all the mail will be in queued. To avoid the messages sent out when it reconnected to the internet, you have an option to empty the mail queue. In this post, i will show how to remove the Postfix Mail Queue using postsuper command.

Also Read :   How to Check Postfix Version

1. Send an email using telnet command :

[[email protected] ~]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 centos63.ehowstuff.local ESMTP Postfix
250 centos63.ehowstuff.local
mail from:
250 2.1.0 Ok
rcpt to:
250 2.1.5 Ok
354 End data with .
subject: Test
250 2.0.0 Ok: queued as DB92A1231
221 2.0.0 Bye
Connection closed by foreign host.

2. To see mail queue, enter the following :

[[email protected] ~]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
DB92A1231*      359 Tue Feb  5 22:14:01  [email protected]
                                         [email protected]

-- 0 Kbytes in 1 Request.

3. Check mail transaction log :

[[email protected] ~]# grep DB92A1231 /var/log/maillog
2013-02-05T22:14:14.899894+08:00 centos63 postfix/smtpd[2406]: DB92A1231: client=localhost[::1]
2013-02-05T22:14:23.843262+08:00 centos63 postfix/cleanup[2422]: DB92A1231: message-id=<[email protected]>
2013-02-05T22:14:23.946379+08:00 centos63 postfix/qmgr[2197]: DB92A1231: from=, size=359, nrcpt=1 (queue active)
2013-02-05T22:14:55.526423+08:00 centos63 postfix/smtp[2423]: DB92A1231: to=, relay=none, delay=54, delays=22/0.02/32/0, dsn=4.4.1, status=deferred (connect to[]:25: Connection timed out)

4. To remove all mails in the deferred queue, enter the following :

[[email protected] ~]# postsuper -d ALL deferred
postsuper: Deleted: 1 message

5. To remove all mail from the queue, enter the following :

[[email protected] ~]# postsuper -d ALL

Leave a Reply