Tired of embarrassing pages of spam subject lines whenever I use my webmail account, I put together these scripts which delete messages from the server that are in a certain folder on my Mac. These scripts require installing mpop, a command line POP client. The following scripts do the work; no doubt they could be refined, a lot, but they work for me.
To use the scripts, use a Mail rule or have cron run the runfilter script. This will generate a list of your current spam message-ids and run mpop. mpop will then use the filter script to see if messages on the server match your spam message listing (using message-id), and delete them if they do.
The scripts assume mpop is installed in /usr/local/bin/, that the 'filter' script is in ~/Documents » Scripts » filter, and that spam email will be found in ~/Library » Mail » Mailboxes » Spam.mbox » Messages. However, you can change these paths in the first script if you wish.
[robg adds: I haven't tested this one.]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20071027113734990