[vox-tech] Scripts for mutt&sylpheed for handling spamcop

Ken Bloom vox-tech@lists.lugod.org
Tue, 17 Dec 2002 20:09:31 -0800


Here are two shell scripts for dealing with SpamCop that I have written.

~/bin/spamcop       is used to submit spam emails to SpamCop.
                    replace the ()()()()()()() with your spamcop submit
                    email address. I used ()()()() so the shell would 
                    choke on the script until you do this.

~/bin/spamcop_web   is used to deal with the emails SpamCop sends asking
                    me which email addresses to send reports to.
                    (I do love lynx, my scriptable web-browser)

Both scripts take an email message with full headers.
For the sake of mutt, they can take it on standard input
For the sake of sylpheed, they can take a filename containing the email

Please note, that I haven't actually given bin/spamcop_web a full test
yet. I haven't recieved any new spam since I wrote it this afternoon.
When I was writing it, I tested it by replacing 'lynx' with 'cat' so I
could see what lynx was getting. I didn't actually want to report any
legitimate emails while I was testing it.

I've been using bin/spamcop for at least 6 months now, so that's been
sufficiently tested

########################## begin ~/bin/spamcop
#! /bin/bash

if [ "$1" ]; then
	cat $1 | $0
	exit 0
fi

mutt submit.()()()()()()()@spam.spamcop.net
exit 0


########################## begin ~/bin/spamcop_web
#! /bin/tcsh

if ($?1)
	cat $1 | $0
	exit 0
end

(echo -n g && grep "http://spamcop.net/sc?id=" && echo /Send Spam  && echo && echo qy) | lynx

##### the comments that follow explain what the last line does #####
#echo -n g                         #tell lynx that you want to go somewhere (no newline after this key)
#grep "http://spamcop.net/sc?id="  #tell it the address, from the email
#echo /Send Spam                   #find the button we need to press by searching for its text
                                   #It says "Send Spam Report(s)" but I didn't
                                   #want to deal with the last word.
#echo                              #press the button with another newline
#echo qy                           #now we're done. quit lynx

exit 0 #disable "press any key" prompt in mutt