Re: [exim] Exim filters: converting strings to numbers?

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Magnus Holmgren
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: Re: [exim] Exim filters: converting strings to numbers?
On Thursday 23 November 2006 11:45, Adam Funk wrote:
> I'm learning to set up Exim filters for sorting mail into Maildir
> folders on my shell account. The hosting company already applies spam
> scores to my incoming mail and adds (for example)
>
> X-Blackcat-Spam-Score:    30.9
> [...]
> Is conversion automatic?  Can I just write

>
>    $h_Blackcat-Spam-Score: is above 9.5


Unfortunately it only works with integers, but if the above score comes from
SpamAssassin via the spam ACL condition you can use $spam_score_int instead.
("This variable is special; it is saved with the message, and written to
Exim's spool file. This means that it can be used during the whole life of
the message on your Exim system, in particular, in routers or transports
during the later delivery phase.") Then your condition becomes:

$spam_score_int is above 95

Otherwise you might be able to create an integer with the substr
operator/item:

"${substr_-6_4:$h_Blackcat-Spam-Score:}${substr_-1_1:
$h_Blackcat-Spam-Score:}" is above 95

This assumes that the score is always less than 10000, that it always has one
decimal, and that there are no stray spaces after the score. Please read
chapter 11 and test yourself.

-- 
Magnus Holmgren        holmgren@???
                       (No Cc of list mail needed, thanks)