Spam nowadays is a real pain. While linux users are fairly safe against most common viiri and spyware, spam mail affects everyone.
While there are many spamfilters out there, I've found that only one is pretty effective, on the long run as well. This guide provides a solution to implementing this filter into KMail for local scanning, filtering and retraining.
A working KMail configuration for scanning and retraining spamfilter with POP3 accounts (IMAP is not supported because mail doesn't really get "downloaded").
A DSPAM 3.6.x using the hash_drv, with training data stored in the user's homedir (~/.dspam)