If you read mail from an IMAP server using multiple mail clients, especially if some of them are mobile (phone/PDA) clients or ones with limited functionality, then you're much better off doing email filtering (spam filtering and/or also other email foldering) on the IMAP email server. Stanford's (Cyrus) IMAP server supports such server-side filtering via writing SIEVE scripts (RFC3028).
The new version of Stanford Webmail (i.e., Imp) provides a web interface to defining SIEVE under the name "Filter Rules". Now, you're almost certainly better off now using that than the instructions below. At any rate, that's what I now do :-).
Here's how you can actually make use of it. These instructions use the Cyrusoft Mulberry program to install filters. A couple of other tools support the server side filtering available on the IMAP server, but very few. None of the more common or Stanford-recommended mail clients will let you do this. You can do all the below with the 30 day demo of Mulberry. Not that I want to discourage you from buying it, but you don't have to buy it to get some filters installed (and, personally, I suspect you won't want to use it as your regular mail client).
http://www.cyrusoft.com/mulberry/SuNetID.pobox.stanford.edu, and, most importantly, in
the Authenticate portion, although it is fine to say that the Method is
"Plain Text" in the upper portion, you need to do something with
the Secure drop box to
encrypt your password in the lower portion, as Stanford no longer allows
unencrypted connections. I used STARTTLS - SSL, and that
seemed to work fine."X-Spam" header for
the stanford.edu spam filter or the
"X-Spam-Status" header for the cs.stanford.edu
spam filter. If you choose the arbitrary
header option in the GUI, you get two text boxes: in the first you type
the header name, and in the second a string, and the test is always
"contains", it appears.
http://www.stanford.edu/~manning/mobile/IMAPfiltering.html