Index of /crappycode/spamSubject
Name Last modified Size Description
Parent Directory 29-Nov-2005 11:52 -
spamSubject 26-Oct-2004 00:33 1k
#!/usr/local/bin/bash
#BEGIN COMMENTS:
#This script randomly extracts SPAM subject lines from your spam folder (I have a procmail rule that
#moves spam assasin taged mail to this folder) and can display them.
#
#I use it with and built it based on the Courier IMAP implementation of the Maildir format for
#storing mail. Which means it probably wont work with mbox files
#I have not tried it with other maildir implementations
#
#I use it as a cgi with an SSI to include it on a web page
#
#You will need to insure that user your webserver runs as has read access to your SPAM folder
#
#I use system time for entropy which it is not, so its not really random but it serves the purpose
#
#The sed expressions strip the subject and duplicate subject which exists becuase of spam assasin
#
#set SPAMDIR to the path to your "cur" folder in your spam directory
#
#END COMMENTS
SPAMDIR=/home/username/Maildir/.spam/cur/
SPAMCOUNT=$(ls $SPAMDIR | wc -l)
RANDOM=$(date +%s)
RANDOMSPAM=$[ ( $RANDOM % $SPAMCOUNT ) + 1 ]
X=0
for SPAM in $(ls $SPAMDIR)
do
let X=$X+1
if [ $X = $RANDOMSPAM ];then
SUBJECT=$(sed -n '/Subject:/p' $SPAMDIR"/"$SPAM )
SUBJECT=$(echo $SUBJECT | sed -e 's/Subject://')
SUBJECT=$(echo $SUBJECT | sed -e 's/Subject:.*//')
echo "Content-type: text/html"
echo
echo
echo "<b>"
echo $SUBJECT
echo "<b>"
break
fi
done