帮酷

Postfix和Dspam在Ubuntu的配置方法

将光标移到/点击文章中的句子上,可以查看原文。 显示译文      显示原文      双语对照


dspAM原作者声明DSPAM已拥有高达99 .5 ~ 99 .95%准确性,包括" 最佳记录级别的精度。。。 99 .987%由作者报告, 99 .991%由一名叫avid用户( 2 个错误在22 ,786 ) 。

 

安装

为了安装Dspam, 首先要使用你喜欢的包管理器从Universe存储库安装 dspam 包。 例如:


sudo aptitude install dspam

安装过程中, 回答问题时只需接受默认值。 下一阶段配置将更详细地进行。

 

配置

dspam的主要有两种配置文件: 1./etc/default/dspam 2. /etc/dspam/dspam.conf

 

dspam配置

编辑第一个文件允许dspam运行:


# Variables for dspam.
#
# Do not start dspam.
START=yes

# User that runs dspam.
USER=dspam

# Options for dspam.
#OPTIONS="--debug"

现在,为了启动dspam作为守护进程,我们将编辑第二个文件: ( 这里是完整的转储文件,而不包含注释行cat /etc/dspam/dspam.conf | egrep -v "^s*(#|$)" )


Home /var/spool/dspam
StorageDriver /usr/lib/dspam/libhash_drv.so
TrustedDeliveryAgent "/usr/sbin/sendmail"
DeliveryHost        127.0.0.1
DeliveryPort        10024
DeliveryIdent       localhost
DeliveryProto       SMTP
OnFail error
Trust root
Trust dspam
Trust mail
Trust mailnull 
Trust smmsp
Trust daemon
Trust postfix
Trust www-data
TrainingMode teft
TestConditionalTraining on
Feature chained
Feature whitelist
Algorithm graham burton
PValue graham
Preference "spamAction=tag"
Preference "signatureLocation=headers"  # 'message' or 'headers'
Preference "showFactors=off"
AllowOverride trainingMode
AllowOverride spamAction spamSubject
AllowOverride statisticalSedation
AllowOverride enableBNR
AllowOverride enableWhitelist
AllowOverride signatureLocation
AllowOverride showFactors
AllowOverride optIn optOut
AllowOverride whitelistThreshold
HashRecMax              98317
HashAutoExtend          on  
HashMaxExtents          0
HashExtentSize          49157
HashMaxSeek             100
HashConnectionCache     10
Notifications   off
PurgeSignatures 14          # Stale signatures
PurgeNeutral    90          # Tokens with neutralish probabilities
PurgeUnused     90          # Unused tokens
PurgeHapaxes    30          # Tokens with less than 5 hits (hapaxes)
PurgeHits1S     15          # Tokens with only 1 spam hit
PurgeHits1I     15          # Tokens with only 1 innocent hit
LocalMX 127.0.0.1
SystemLog on
UserLog   on
Opt out
TrackSources spam ham
ParseToHeaders on
ChangeModeOnParse on
ChangeUserOnParse on
ServerPort              11124
ServerQueueSize         32
ServerPID              /var/run/dspam/dspam.pid
ServerMode auto
ServerParameters        "--deliver=innocent -d %u"
ServerIdent             "localhost.localdomain"
ClientHost      127.0.0.1
ClientPort      11124
ProcessorBias on
Include /etc/dspam/dspam.d/

如你所见,我们要守护进程绑定到localhost端口来获得更高的性能。

 

Postfix整合

现在, 实现Postfix跟Dspam通信 。

编辑 /etc/postfix/master.cf 并加入下面两行;


# DSPAM
127.0.0.1:10024 inet n  -       n       -        -      smtpd
        -o smtpd_authorized_xforward_hosts=127.0.0.0/8
dspam-retrain   unix    -       n       n       -       10      pipe
  flags=Ru user=dspam argv=/etc/dspam/dspam-retrain $nexthop $sender $recipient

然后:


smtp      inet  n       -       -       -       -       smtpd

dspam-retrain将包垃圾邮件传递给dspam训练。

现在编辑 /etc/postfix/main.cf 和"替换:


smtpd_client_restrictions = 

最后一行( 通常在单词中结束 允许 ),如下:


        check_client_access pcre:/etc/postfix/dspam_filter_access
        permit_auth_destination

你应该得到类似:


smtpd_client_restrictions = 
        permit_mynetworks
        [...]
        check_client_access pcre:/etc/postfix/dspam_filter_access
        permit_auth_destination

还要在某个地方添加( 通常在文件的结尾) 以下内容:


# DSPAM
dspam_destination_recipient_limit = 1

/etc/postfix/dspam_filter_access 文件应该包含连接到dspam lmtp守护进程:


/./   FILTER lmtp:[127.0.0.1]:11124

现在修改 /etc/postfix/transport 创建规则的训练地址:


spam@your.domain.tld   dspam-retrain:spam
ham@your.domain.tld    dspam-retrain:innocent

最后,创建一个文件用来解析训练dspam的邮件。 创建一个perl脚本 /etc/dspam/dspam-retrain 为下面的内容:


# Get arguments
$class  = $ARGV[0] || die; shift;
$sender = $ARGV[0] || die; shift;
$recip  = $ARGV[0] || die; shift;

if ($recip =~ /^(spam|ham)-(w+)@/) {
    # username is part of the recipient
    $user = $2;
} elsif ($sender =~ /^(w+)@/) {
    # username is in the sender
    $user = $1;
} else {
    print "Can't determine usern";
    exit 75;                    # EX_TEMPFAIL
}

# Pull out DSPAM signatures and send them to the dspam program
while (<>) {
    if ((! $subj) && (/^Subject: /)) {
        $subj = $_;
    } elsif (/(!DSPAM:[a-f0-9]+!)/) {
        open(F, "|/usr/bin/dspam --source=error --class=$class --user $user");
        print F "$subjn$1n";
        close(F);
    } elsif (/(X-DSPAM-Signature: [a-f0-9]+)/) {
        open(F, "|/usr/bin/dspam --source=error --class=$class --user $user");
        print F "$subjn$1n";
        close(F);
    }
}

别忘记添加" # ! /usr/bin/perl " 和执行权限文件:


chmod +x /etc/dspam/dspam-retrain

 

服务管理

启动,停止或重新启动服务,请使用:


invoke-rc.d dspam start
invoke-rc.d dspam stop
invoke-rc.d dspam restart

也启动Dspam守护进程后,不要忘记重启Postfix :


invoke-rc.d postfix restart

 

调试

使用 dspam_stats -H 统计信息的监控。

另外,你的邮件现在应该包含dspam头签名。 所示:


X-DSPAM-Result: Innocent
X-DSPAM-Processed: Tue Jun 16 20:25:03 2009
X-DSPAM-Confidence: 1.0000
X-DSPAM-Probability: 0.0023
X-DSPAM-Signature: 4a37d56f12661069814937

就这些了。




Copyright © 2011 HelpLib All rights reserved.    知识分享协议
京ICP备05059198号-3