[Cialug] Postfix Mail Queue
David W. Body
cialug@cialug.org
Tue, 30 Nov 2004 10:25:32 -0600
> Is there any easy to grab messages from the Postfix mail queue? For
> example,
> I'd like to take the results frm postqueue -p and be able to view an item
> by
> its ID. I know that the messages are in /var/spool/postfix, but how do I
> tell what queue they are in?
>
I use the following, which is from Postfix: The Definitive Guide (O'Reilly,
2004):
-----------------------------------------------------
#!/bin/sh
PATH=/usr/bin:/usr/sbin
QS="deferred active incoming maildrop hold"
QPATH=`postconf -h queue_directory`
if [ $# -ne 1 ]; then
echo "Usage pfcat <queue id>"
exit 1
fi
if [ `whoami` != "root" ]; then
echo "You must be root to view queue files."
exit 1
fi
if [ ! -d $QPATH ]; then
echo "Cannot locate queue directory $QPATH."
exit 1
fi
for q in $QS
do
FILE=`find $QPATH/$q -type f -name $1`
if [ -n "$FILE" ]; then
postcat $FILE
exit 0
fi
done
if [ -z $FILE ]; then
echo "No such queue file $1"
exit 1
fi
-----------------------------------------------------
--David W. Body / Big Creek Software, LLC