Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have exim and spamassassin (used by exiscan) installed and running, but i want to add custom rule which will add some points to emails if "to" and "envelope-to" are not identical. I added following rules to

header      EXIM_SENDER_SWAP        X-Sender-Swap =~ /To_envelope-to/
describe    EXIM_SENDER_SWAP        To doesnt match envelope-to
score       EXIM_SENDER_SWAP        2.0

and line in exim.conf


      warn message = X-Subject-Swap: To_envelope-to
          condition = ${if !match {${lc:$h_envelope-to:}}{${lc:$h_to:}}{yes}{no}}

I am sending test message and corresponding header is added by exim, but no additional poinst added by spamassassin. What's wrong?

share|improve this question
up vote 1 down vote accepted

First, the "message" modifer is not what you want, instead you want to use "add_header" when you want to add a header to a message in an ACL. Read if you need more information on that part.

However, I don't think what you're trying to do will work in the manner than you are using. In the guts of exim as it's processing each ACL, the ACL is run, then when the ACL has completed, all header additions and deletions are done. You are doing both of these in the same DATA ACL, which means that the headers added by the first comparison have not yet actually been added to the message in the temp files that the spam command is scanning.

One option is to do the spam scan, detect the condition where you would have added the header, and then add that score to the variable that holds the spam score when comparing to see if it's spam.

A second option, and the better one in my opinion, is to have two different users that you use to run the spam scan. For one you have the spam score set to (for example) 5.0. For the second one, you have the spam score set to 3.0. This is 2 points less than the normal limit, which is the same as having added 2 points to the spam score.

Then your ACL stanzas could look like (untested):

warn condition = ${if !match {${lc:$h_envelope-to:}}{${lc:$h_to:}}{yes}{no}}
     set $acl_m_env_ok = 1
     spam = strict_user:true

warn condtion = ${if eq{$acl_m_env_ok}{1} {no}{yes}}
     spam = normal_user:true

warn add_header = X-Spam-Score: $spam_score
     add_header = X-Spam-Report: $spam_report

deny condition  = ${if eq{$acl_m_env_ok}{1}}
     condition  = ${if >{$spam_score_int}{30}}
     message    = This message with mismatched header/envelope score $spam_score_points...REJECTED

deny condition  = ${if >{$spam_score_int}{50}}
     message    = This message scored $spam_score points...REJECTED
share|improve this answer
Now that I look at the deny stanza, I realize it's only rejecting based on the normal score. I added a second stanza to reject the 3 point score as well in the case of the mismatched header versus envelope. – Todd Lyons Oct 17 '12 at 14:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.