From: joe on
Hello everyone, I wrote a little script to delete all email to a
domain. seems to work, although it is not perfect. I was looking for
this script online and I was unable to find it so here it is


mailq |grep -i -B 1 mydomain.com|sed 's/--//g'|cut -f 1 -d ' '|sed 's/
*//g'|sed 's/ //g'|sed '/^$/d'|while read line; do postsuper -d
$line ; done

From: ivakras1 on
On 27 , 16:02, joe <jcha...(a)gmail.com> wrote:
> Hello everyone, I wrote a little script to delete all email to a
> domain. seems to work, although it is not perfect. I was looking for
> this script online and I was unable to find it so here it is
>
> mailq |grep -i -B 1 mydomain.com|sed 's/--//g'|cut -f 1 -d ' '|sed 's/
> *//g'|sed 's/ //g'|sed '/^$/d'|while read line; do postsuper -d
> $line ; done

Just correct that example:

#man postsuper
....
-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(a)example.com:

HERE -> mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS =
"" }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($8 == "user(a)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 message
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 post-
super(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
supposed to
delete. The probability for reusing a deleted
queue ID
is about 1 in 2**15 (the number of different
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.


From: Ralf Hildebrandt on
On 2007-07-27, joe <jcharth(a)gmail.com> wrote:

> Hello everyone, I wrote a little script to delete all email to a
> domain. seems to work, although it is not perfect. I was looking for
> this script online and I was unable to find it so here it is

http://www.google.de/search?q=delete_from_mailq

--
Ralf Hildebrandt (i.A. des IT-Zentrums) Ralf.Hildebrandt(a)charite.de
Charite - Universitätsmedizin Berlin Tel. +49 (0)30-450 570-155
Gemeinsame Einrichtung von FU- und HU-Berlin Fax. +49 (0)30-450 570-962
IT-Zentrum Standort CBF send no mail to plonk(a)charite.de