imapfilter.pl is a set of perl scripts that can help you to automate filtering emails. The script(s) can run in cron on a regular basis. First you need to download, unpack and install the scripts some place on your server. Then, you have to create a rule.txt file which might contain several lines. For example: