you must configure a sieve script, i just doing it with cyrus deliverer and sieve scripting :
here an example from a sieve script to filter some mails and spam.
(this works for altnamespace=yes in /etc/imapd.conf)
require "fileinto";
if header :contains "from" "fax@segundo.plastecnia.cl" {
fileinto "Hylafax";
}
elsif header :contains "from" "fax@plastecnia.cl" {
fileinto "Hylafax";
}
elsif header :contains "X-Spam-Flag" "YES" {
fileinto "SPAM";
}