I used to use a completely perl based procmail replacement but I can't seem to find the name of it. I've since switched to procmail. Here are some tools for dealing with incoming mail, most probably what you want to do.
PMSMail::FilterMail::AuditSendmail::Milter