Partager via


Spam Filter

Topic Last Modified: 2006-06-12

The primary purpose of the spam filter is to evaluate a message and set the spam confidence level (SCL) value on the message. Once the filter has set the SCL value on the message, the filter should then compare the SCL value of the message to the Block Threshold value. If the SCL value for the message exceeds the Block Threshold, the filter should then apply a custom action to the message. If the SCL value for the message is equal to or less than the Block Threshold, the filter should add the SCL value to the message and transmit the message to the mailbox server. For information about the actions provided with the protocol sink template, see Protocol Sink Template. The Spam Confidence Level topic contains information about the available SCL values.

The protocol sink template contains the following code as a simple example of how to evaluate a message and set the SCL value on the message. In the example, the rating included in the message subject, such as "UCE6", determines the SCL rating for the message. In this case, the SCL value for the message would be set to 6. This code needs to be replaced with your own custom algorithm for determining spam content. This documentation does not include information about how to write custom anti-spam algorithms.

    //-----------------------------------------------------------------------
    // Set the ContentFilter result based on the text in the Subject MailMsg Property     
    //-----------------------------------------------------------------------
    szMsgSubject[0] = '\0';

    // Set spam confidence level to 0 and probability to 0
    *pdwSCL = 0;
    *pdwProbability = 0;

    hr = pIMsg->GetStringA(
            IMMPID_MP_RFC822_MSG_SUBJECT,
            sizeof(szMsgSubject) / sizeof(CHAR),
            szMsgSubject);

    if (NULL != strstr(szMsgSubject, "UCE1"))
    {
        // Set spam confidence level to 1 and probability to 60%
        *pdwSCL = 1;
        *pdwProbability = 6000;
    }
    else if (NULL != strstr(szMsgSubject, "UCE2"))
    {
        // Set spam confidence level to 2 and probability to 80%        
        *pdwSCL = 2;
        *pdwProbability = 8000;
    }
    else if (NULL != strstr(szMsgSubject, "UCE3"))
    {
        // Set spam confidence level to 3 and probability to 90%        
        *pdwSCL = 3;
        *pdwProbability = 9000;
    }
    else if (NULL != strstr(szMsgSubject, "UCE4"))
    {
        // Set spam confidence level to 4 and probability to 93%
        *pdwSCL = 4;
        *pdwProbability = 9300;
    }
    else if (NULL != strstr(szMsgSubject, "UCE5"))
    {
        // Set spam confidence level to 5 and probability to 96%       
        *pdwSCL = 5;
        *pdwProbability = 9600;
    }
    else if (NULL != strstr(szMsgSubject, "UCE6"))
    {
        // Set spam confidence level to 6 and probability to 98%       
        *pdwSCL = 6;
        *pdwProbability = 9800;
    }
    else if (NULL != strstr(szMsgSubject, "UCE7"))
    {
        // Set spam confidence level to 7 and probability to 99%       
        *pdwSCL = 7;
        *pdwProbability = 9900;
    }
    else if (NULL != strstr(szMsgSubject, "UCE8"))
    {
        // Set spam confidence level to 8 and probability to 99.6%       
        *pdwSCL = 8;
        *pdwProbability = 9960;
    }
    else if (NULL != strstr(szMsgSubject, "UCE9"))
    {
        // Set spam confidence level to 9 and probability to 99.99%       
        *pdwSCL = 9;
        *pdwProbability = 9990;
    }