使用 exim4 添加 X-Spam-Flag

使用 exim4 添加 X-Spam-Flag

我是 exim4 的新手。我的配置如下:

.ifdef SA_ENABLE
        warn
            !authenticated = *
            hosts = !127.0.0.1/24
            condition = ${if < {$message_size}{1K}}
            spam       = SA_SPAMD_USER:true
            add_header = X-Spam_score: $spam_score\n\
                   X-Spam_score_int: $spam_score_int\n\
                   X-Spam_bar: $spam_bar\n\
                   X-Spam_report: $spam_report

        warn
            !authenticated = *
            hosts = !+relay_from_hosts
            spam       = SA_SPAMD_USER:true/defer_ok
            add_header = X-Spam_score: $spam_score\n\
                    X-Spam_score_int: $spam_score_int\n\
                    X-Spam_bar: $spam_bar\n\
                    X-Spam_report: $spam_report
            set acl_m4 = $spam_score_int
            condition = ${if and{{<{$message_size}{100K}}{<{$acl_m4}{SA_SCORE_REJECT}}} {yes}{no}}
            logwrite = From $sender_address to $recipients X-Spam_score: $acl_m4.

        deny
            condition = ${if and{{>{$message_size}{10K}}{!eq{$acl_m4}{}}{>{$acl_m4}{SA_SCORE_REJECT}}} {yes}{no}}
            message = Content analisis tool detect spam (from $sender_address to $recipients). Contact SA_ABUSE_ADDR.
.endif

如果分数高于/低于某个值,我该如何调整以添加 X-Spam-Flag(是或否),如果高于其他值,则拒绝。(目前 SA_SCORE_REJECT = 50)

答案1

如果我想强制执行两个单独条件的 AND ,我发现将它们写成两个单独的状况条款。我认为这会起作用:

# Define constants
SA_MESSAGE_SIZE=100K
SA_SCORE_FLAG=50
SA_SCORE_REJECT=100

.ifdef SA_ENABLE
    warn
        !authenticated = *
        hosts = !127.0.0.0/8 : !+relay_from_hosts
        condition = ${if <{$message_size}{SA_MESSAGE_SIZE}}
        spam       = SA_SPAMD_USER:true
        set acl_m4 = $spam_score_int
        add_header = X-Spam_score: $spam_score\n\
               X-Spam_score_int: $spam_score_int\n\
               X-Spam_bar: $spam_bar\n\
               X-Spam_report: $spam_report

    warn
        !authenticated = *
        hosts = !127.0.0.0/8 : !+relay_from_hosts
        condition = ${if <{$message_size}{SA_MESSAGE_SIZE}}
        condition = ${if >{$acl_m4}{SA_SCORE_FLAG}}
        add_header = X-Spam-Flag: YES
        logwrite = From $sender_address to $recipients X-Spam_score: $acl_m4.

# Reject spam messages with score*10 over SA_SCORE_REJECT=100
    deny
        !authenticated = *
        hosts = !127.0.0.0/8 : !+relay_from_hosts
        message = Content analysis tool detect spam (from $sender_address to $recipients). Contact SA_ABUSE_ADDR.
        condition = ${if <{$message_size}{SA_MESSAGE_SIZE}}
        condition = ${if >{$acl_m4}{SA_SCORE_REJECT}}
        logwrite = From $sender_address to $recipients spam message was rejected X-Spam_score: $acl_m4. 
.endif

$spam_score_int=100 等于 $spam_score=10.0

相关内容