[Exim] Header magic

Top Page
Delete this message
Reply to this message
Author: Jens Vonderheide
Date:  
To: exim-users
Subject: [Exim] Header magic
Hi all,

I have run into some difficulties involving headers_add/headers_remove and
don't know how to continue.
All these problems result from my attempts to combine the spam-detection
of exiscan with user configurations.

1) In a bouncing router, can I remove a header added in the DATA ACL? I am
using this router (slighty reduced to increase readability) to bounce
messages with a spam score (obtained by exiscan-acl)

spam_bounce:
    driver = redirect
    address_data = ${lookup mysql{MYSQL_CHECKDATA}{$value}fail}
    data = ${if <condition to match on spam score>
        {:fail: This message was classified as spam} \
        {:unknown:}}
    headers_remove = X-Spam-Report
    allow_fail
    no_verify


But in the bounce message, the X-Spam-Report header is still there.

2) For a lower spam score, I want to modify the subject and add a header.
I cannot use a system filter, as this does not set $local_part for
messages with multiple recipients. I can neither use a "simulated" system
filter (39.8 in the manual), as the headers_add/remove functions are not
allowed in user filters.
So I have tried to do this using this router (again reduced):

spam_subject:
    driver = redirect
    address_data = ${lookup mysql{MYSQL_CHECKDATA}{$value}fail}
    headers_remove = ${if spamscore > user-defined level
        {subject} \
        {}}
    headers_add = ${if <spamscore > user-defined level>
        {X-Spam: Yes\
         ${if <modify subject>\
                 {\nSubject: ***SPAM*** $h_subject:}{} } } \
        {}}
    data = ${quote:$local_part}@$domain
    redirect_router = virtual_forward
    no_verify


virtual_forward is the next router in my configuration, so I'm
unconditionally "passing on" to the next router.
This works surprisingly well. The only problem is that virtual_forward may
redirect to another local address, again running the spam_subject router
and adding a second set of X-Spam and Subject headers.

I've tried replacing the data line with
data = ${if first_delivery {${quote:$local_part}@$domain}{:unknown:}}
but this skips the router for any further local addresses.

Any ideas how I could solve this?

Jens