Exim filter

Exim filters are a simpler language than sieve or procmail, if you wish to do simple filtering without any advanced features, then an exim filter will likely work.  The full documentation for exim filters is available on the exim website.

At the School of Mathematics, Exim filters are stored in .forward files. 

An example .forward that will filter email marked spam is show below:

# Exim filter

logfile $home/filter.log 0644

if $sender_address contains "proofpoint-pps"
then
  logwrite "$message_id proofpoint"
  seen finish
endif

if $header_X-Spam-Status begins Yes
then
  logwrite "$message_id spam"
  seen finish
endif
 
This .forward will also log an entry in filter.log when a message is rejected by the filter.
This filtering language is the simplest to learn but does not have any advanced features. 
 

Filtering before Forwarding

You may use the exim filter as a "Smart Forward"  In the above example, we filter SPAM, at the end of the forward we can put a deliver line to deliver to another address.  If we wanted to forward to madeupmathaccount@gmail.com, the .forward would look like the following:
# Exim filter

logfile $home/filter.log 0644

if $sender_address contains "proofpoint-pps"
then
  logwrite "$message_id proofpoint"
  seen finish
endif

if $header_X-Spam-Status begins Yes
then
  logwrite "$message_id spam"
  seen finish

deliver madeupmathaccount@gmail.com