deletemailqueue
Permanently delete every email waiting in the Postfix mail queue
- Command:
/go/deletemailqueue - Category: Mail
- Required option: None
- Output: A short status line, then Postfix's deletion counts
- Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Output · Examples · Troubleshooting · Details · See also
Overview
/go/deletemailqueue empties the Postfix mail queue in one step. Use it when the queue is full of unwanted mail, for example after a compromised account or a script has sent out spam, and you want a clean start.
[!WARNING] There is no confirmation prompt and no undo. Every queued message is deleted, including legitimate mail that is still waiting to be delivered. The senders are not notified.
To remove only undeliverable mail, use undelivered instead.
Quick start
# Check what is in the queue first
mailq | tail -n 1
# Delete everything in the queue
/go/deletemailqueue
Syntax
/go/deletemailqueue
The command takes no options. Any arguments you pass are only recorded in the log, and they change nothing.
Run it as root, or as a user that can use sudo.
Output
Deleting mail queue...
postsuper: Deleted: 1284 messages
postsuper: Deleted: 0 messages
The first line is printed by the command. The postsuper lines come from Postfix and show how many messages were removed. The exact wording can vary by Postfix version. The second count is normally 0, because the first step has already removed everything (see What it does).
If the queue was already empty, both counts are 0.
Examples
# Count the queued messages before and after
mailq | tail -n 1
/go/deletemailqueue
mailq | tail -n 1
# Find out who is sending the mail first
/go/mailtop
/go/subjecttop
# Delete just one message instead of the whole queue
mailq
sudo postsuper -d <queue-id>
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The queue fills up again right after | Something is still sending mail, such as a compromised mailbox or a script. | Find the source with mailtop, subjecttop, or spam, then fix it. Deleting the queue does not stop the sender. |
Permission denied or a sudo prompt |
The command was not run with enough privileges. | Run it as root. |
| Customers say mail they sent never arrived | Their messages were still in the queue when it was deleted. | They need to send it again. Deleted messages can't be recovered. |
Deleted counts are 0 but mail is still listed |
New mail arrived after the command ran, or mailq shows mail from before. |
Run mailq again. |
| I only wanted to remove some messages | This command removes everything. | Delete specific messages with postsuper -d <queue-id>, or use undelivered. |
Details
What it does
- Appends the call, with a timestamp and its arguments, to
/var/log/go/deletemailqueue.log. - Prints
Deleting mail queue.... - Runs
postsuper -d ALL, which deletes all messages from Postfix's queues (incoming, active, deferred, and hold). - Runs
postsuper -d ALL deferred, which deletes the messages in the deferred queue.
Step 4 is normally redundant, because step 3 already includes the deferred queue. It does no harm.
Side effects
- The deleted messages are gone permanently. The log records only that the command was run, not which messages were removed.
- No bounce or failure notice is sent to the original senders.
- Postfix keeps running. New mail is accepted and queued as usual.
See also
| Command | Description |
|---|---|
undelivered |
Delete undeliverable emails in GoAdmio |
mailtop |
Check the most active email accounts in GoAdmio |
subjecttop |
Report the most common email subjects in the Postfix maillog |
spam |
Track spam email accounts in GoAdmio |
outgoing |
Report today's outbound mail sessions |
postfwd |
Build the Postfwd rate-limiting rules |
troubleshoot |
Troubleshoot email problems in GoAdmio |