Postfix queue administration

Although I’ve used many MTA’s before, I’m new to postfix so here’s a few handy commands to note:

List the mail queue:
postqueue -p

Delete a single message:
postsuper -d 4C63F2300BA

Flush the queue (attempt to deliver all queued mail)
postfix flush
postfix -f

To remove all mail from the queue:
postsuper -d ALL

To remove all mail in the deferred queue:
postsuper -d ALL deferred

A handy script to delete all mail in the queue which matches a regex:

$REGEXP = shift || die “no email-adress given (regexp-style, e.g. bl.*\!”;

@data = qx;
for (@data) {
if (/^(\w+)(\*|\!)?\s/) {
$queue_id = $1;
if($queue_id) {
if (/$REGEXP/i) {
$Q{$queue_id} = 1;
$queue_id = “”;

#open(POSTSUPER,”|cat”) || die “couldn’t open postsuper” ;
open(POSTSUPER,”|postsuper -d -“) || die “couldn’t open postsuper” ;

foreach (keys %Q) {
print POSTSUPER “$_\n”;

./ xyz

Thanks to cyberciti for this one

You can leave a response, or trackback from your own site.

Leave a Reply