Can Sieve Scripts Use Functions Defined Via Mapping Tables?

Can Sieve Scripts Use Functions Defined Via Mapping Tables?

Yes, Sieve scripts can use functions defined via mapping tables. In particular a Sieve script can use a function that is implemented as a mapping table that does a dns_verify routine call to query spamhaus.

Although this mapping-table-as-Sieve-function functionality has existed for quite awhile, the syntax doesn't settle down until Messaging Server 6.3. For Messaging Server 6.2, you can do this with a bit of an incompatibility in the variables usage. (This document does not address releases prior to Messaging Server 6.2.)

  • In Messaging Server 6.3, to have a Sieve function that is a mapping table, create a mapping table named FILTER_function-name, for example:
    FILTER_foo
    
      a     b$Y
    

    A Messaging Server 6.3 Sieve script can then accomplish something like the following:

    require "variables";
    if foo "a" {set "foo-result" "{$0}";
                set "foo-flags" "{$1}";
                if string :is ${foo-result} "b" { hold; }
               }
    

    This Sieve script sets foo-result to b and foo-flags to Y, and .HELD the incoming message.

  • In Messaging Server 6.2, to have a Sieve function that is a mapping table:
    require "variables";
    if foo "a" {set "foo-result" "{$1}";
                set "foo-flags" "{$2}";
                if string :is ${foo-result} "b" { hold; }
               }
    

    Note the different variable numbering.

In general, the idea is to have a mapping table (say FILTER_spamhaus) that uses a dns_verify callout to query spamhaus. Have your Sieve script check for relevant header lines that might have a source IP, then call the spamhaus function (which is the FILTER_spamhaus mapping) passing in to the function/mapping the source IP your script found (and stored in one variable) and getting back a spamhaus result in another variable; check that returned variable and based upon it do something useful, whatever you consider useful: discard the message, reject it, .HELD it with the "hold" action, do a "spamadjust", and so on.

Labels

messagingserver messagingserver Delete
faq faq Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact