POPFile is a Baynesian, open source (and obviously totally free) program that checks your messages for spam and then labels them as such. Once the e-mail is identified you can filter is using your normal software.

Generally only works for POP3 e-mail, but there are work arounds for webmail as well.