Stu,

Here is how I have handled the cleaning up of enqueued messages.
(Comments to follow)

#!/bin/sh

if [ $# -lt 4 ] ; then
        echo "Usage: $0 MAIL_FROM DayOfWeek Month Date" ; exit
fi

mail_from=$1
dow=$2
month=$3
date=$4
date_regex="$2[[:space:]]+$3[[:space:]]+$4"
report_to=`whoami`

awk=' /$date_regex.+$mail_from/ { getline; getline; print $1; }'

e1=`echo $mail_from | cut -d'@' -f1`
e2=`echo $mail_from | cut -d'@' -f2`

postqueue -p | awk "/$date_regex.+$mail_from/ "'{ getline; getline;
print $1; }' | mail -s "Undeliverables: $dow $month $date - $e1 at
$e2" $report_to
postqueue -p | awk "/$date_regex.+$mail_from/ "'{ print $1; }' | tr -d
'*!' | postsuper -d -

#end

As you can see, I'm not a great shell scripter, but I know enough to
be dangerous. The basic idea is that I could grab messages that were
undeliverable from a certain sender address ($mail_from) on a certain
date ($dow $month $date) and email the undeliverable addresses to
myself. I then grab the message ids and feed them to postsuper in
order to delete them from the queue.

Like I said, I'm sure there is a better way to handle this- in
particular, the combination of shell script and awk was really awkward
(no pun intended). Even just looking at it now makes me think I should
have written the entire thing in awk (although I know even less about
awk).

Let me know if you have any further questions

Clint

> Hi Clint,
>
> Would you mind posting your script/strategy on cleaning these messages
> out? Not to help me answer your question, but because I would love to do
> what you have done yourself :-)
>
> Thanks,
> Stu
>

Reply via email to