Postfix mailq search
I couldn’t find a script to search the Postfix mail queue so I wrote one. It’s a bash script and can be downloaded here (or just copy and paste it to file of your choice). I call it ssubject.sh. It ends up just spitting out the queue id’s of messages that match. Usage: “ssubject.sh “some words to look for”
-
#!/bin/bash
-
-
SUBJECT=$1
-
-
/usr/sbin/postqueue -p | awk {'print $1'} | grep -v (host | \
-
grep -v @ | grep -v (delivery | grep -v (Host | grep -v (connect | \
-
grep -v (lost | grep -v (conversation | grep -v -Queue | \
-
sed 's/*//g' | sed '/^$/d' > /tmp/queue_ids.txt
-
-
cat /tmp/queue_ids.txt | while read line; do
-
sudo /usr/sbin/postcat -q ${line}|> | grep "$SUBJECT" > /dev/null 2>&1
-
if [ "$?" -eq "0" ]; then
-
echo ${line}|> ;
-
fi
-
done
. This entry was posted on Thursday, July 12th, 2007 at 8:21 am and is filed under Code, E-Mail, Postfix. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply
XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>It may take some time for your comment to appear, it is not necessary to submit it again.