Conditionally rewriting mail subjects using exim4

Since MobileMe sadly does not support filtering using RegExps, and I get a lot of heterogenous system mails from our computer systems here, I implemented a workaround. I added some text like [System] to the subject, which can be filtered fine by MobileMe.

All of our machines here send their mail to a central smarthost running exim4. All the system mails are directed to “root” at some of our machines. What I did was first adding a file /etc/exim4/exim.filter containing this:

# Exim filter
if "$h_to:" matches Nroot@.*.your.domain.deN then
headers add "New-Subject: [System] $h_subject:"
headers remove subject
headers add "Subject: $h_new-subject:"
headers remove new-subject
Since we are running Debian, running exim4 in split configuration, I also added the file /etc/exim4/conf.d/main/80_exim4-config_system_filter, containing this:

system_filter = /etc/exim4/exim.filter

After that I had to run update-exim4.conf and /etc/init.d/exim4 reload. Then I was all set up.

Leave a Reply

Your email address will not be published.