首页 > 代码库 > Postfix 删除队列中的邮件
Postfix 删除队列中的邮件
#man postsuper
NAME
postsuper - Postfix superintendent
SYNOPSIS
postsuper [-psv] [-c config_dir] [-d queue_id]
[-h queue_id] [-H queue_id]
[-r queue_id] [directory ...]
-d queue_id
Delete one message with the named queue ID from the named mail queue(s) (default: hold, incoming, active and
deferred).
If a queue_id of - is specified, the program reads queue IDs from standard input. For example, to delete all
mail with exactly one recipient user@example.com:
mailq | tail +2 | grep -v ’^ *(’ | awk ′BEGIN { RS = "" }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($8 == "user@example.com" && $9 == "")
print $1 }
′ | tr -d ’*!’ | postsuper -d -
Specify "-d ALL" to remove all messages; for example, specify "-d ALL deferred" to delete all mail in the
deferred queue. As a safety measure, the word ALL must be specified in upper case.
Warning: Postfix queue IDs are reused. There is a very small possibility that postsuper deletes the wrong mes-
sage file when it is executed while the Postfix mail system is delivering mail.
The scenario is as follows:
1) The Postfix queue manager deletes the message that postsuper(1) is asked to delete, because Postfix is
finished with the message (it is delivered, or it is returned to the sender).
2) New mail arrives, and the new message is given the same queue ID as the message that postsuper(1) is sup-
posed to delete. The probability for reusing a deleted queue ID is about 1 in 2**15 (the number of dif-
ferent microsecond values that the system clock can distinguish within a second).
3) postsuper(1) deletes the new message, instead of the old message that it should have deleted.