Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 local.cf:

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

  acl_check_data:

      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

1 Answer 1

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 http://www.exim.org/exim-html-current/doc/html/spec_html/ch42.html#SECTaddheadacl 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

 
discard

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.