Re: [Exim] String expansion: repeat a character sequence n t…

Top Page
Delete this message
Reply to this message
Author: Sheldon Hearn
Date:  
To: Matt Bernstein
CC: exim-users
Subject: Re: [Exim] String expansion: repeat a character sequence n times
On (2003/11/28 13:09), Matt Bernstein wrote:

> >  headers_add = \
> >    ${if \
> >      match {$h_X-Spam-Score:}{${repeat{\\\\+}{MAILBOX_SPAMTAG_THRESH}}} \
> >      {Subject: ***SPAM*** $h_Subject:} {} \
> >    }

> >
> >Hope springs eternal. :-)
>
> ..which is why you can embed a nice Perl interpreter ;)


Urgh, no thanks. :-)

While perl integration provides awesome power, it also beefs up Exim's
footprint beyond what I'm comfortable with in this case.

But your suggestion to use Perl brought regex back to mind. Thanks.

1) Modify ACL to include int spam score:

  warn message = X-Spam-Score: $spam_score ($spam_bar) [INT $spam_score_int]
       spam = nobody:true


2) Now hack the crap out of the headers_remove and headers_add options
in my transport:

...
# The SpamTagScore value should be zero or the $spam_score_int value
# above which the Subject line will be tagged.
#
MAILBOX_SPAMTAG_THRESH= \
  ${lookup \
    pgsql{ \
      SELECT SpamTagScore \
        FROM Mailbox \
       WHERE Name = '${quote_pgsql:$local_part}' \
    } \
    {$value} \
    {0} \
  }
...


local_delivery:
  ...
  headers_remove = \
    ${if \
      and { \
        { ! ={MAILBOX_SPAMTAG_THRESH}{0} } \
        { \
          >{${sg{$h_X-Spam-Score:}{\N^.*\[INT (\d+)\]\N}{\$1}}} \
           {MAILBOX_SPAMTAG_THRESH} \
        } \
      } \
      {subject} \
      {} \
    }
  headers_add = \
    ${if \
      and { \
        { ! ={MAILBOX_SPAMTAG_THRESH}{0} } \
        { \
          >{${sg{$h_X-Spam-Score:}{\N^.*\[INT (\d+)\]\N}{\$1}}} \
           {MAILBOX_SPAMTAG_THRESH} \
        } \
      } \
      {Subject: ***SPAM*** $h_Subject:} \
      {} \
    }


Ciao,
Sheldon.