Sun Java System Messaging Server 6.3 Administration Guide

ProcedureTo Add a Header Containing SpamAssassin Score to Spam Messages

This example adds the header Spam-test: result string to messages determined to be spam by SpamAssassin. An example header might be:

Spam-test: True ; 7.3 / 5.0

where Spam-test: is a literal and everything after that is the result string. True means that it is spam (false would be not spam). 7.3 is the SpamAssassin score. 5.0 is the threshold. This result is useful for setting up a Sieve filter that can file or discard mail above or between a certain score.

In addition, setting USE_CHECK to 0 returns the list of SpamAssassin tests that matched along with the verdict string. See USE_CHECK in Table 14–3.

  1. Specify the messages to be filtered. This is described in Step 3 in To File Spam to a Separate Folder

  2. Create the SpamAssassin configuration file.

    The name and location of this file is specified with spamfilter_configX_file (see next step). It consists of the following lines:


    host=127.0.0.1
    port=2000
    mode=1
    field=
    debug=1
                      

    host and port specify the name of the system where spamd is running and the port on which spamd listens for incoming requests. mode=1 specifies that the SpamAssassin result string is returned if the message is found to be spam. field= specifies a string prefix for the SpamAssassin result string. In this example, a prefix is not desired because we are specifying it in the Sieve script. debug=1 turns on debugging in the SpamAssassin library.

  3. Add the following lines to the option.dat file:


    !for Spamassassin
    spamfilter1_config_file=/opt/SUNWmsgsr/config/spamassassin.opt
    spamfilter1_library=/opt/SUNWmsgsr/lib/libspamass.so
    spamfilter1_optional=1
    spamfilter1_string_action=data:,require ["addheader"];addheader "Spam-test: $U";
    

    As in previous examples, the first three options specify the SpamAssassin configuration file, shared library, and to continue MTA operation if there is a failure by the shared library. The following line:

    spamfilter1_string_action=data:,require ["addheader"];addheader "Spam-test: $U";

    specifies that a header is added to spam messages. The header has the literal prefix Spam-text: followed by the string returned by SpamAssassin. Because mode=1 was specified in the previous step, the SpamAssassin result string is returned. For example: True; 7.3/5.0

  4. Recompile the configuration, restart the server and start the spamd daemon.

    See 14.4.5 SpamAssassin Configuration Examples.