Chinaunix首页 | 论坛 | 博客
  • 博客访问: 35869
  • 博文数量: 13
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-06 10:48
文章分类

全部博文(13)

文章存档

2011年(1)

2009年(12)

我的朋友
最近访客

分类:

2009-11-29 15:51:04

为了做测试,先把Debian5.0的basesystem给装上了,接下来就是安装Postfix和Dspam即可

先说下我的使用源是:

deb sid main contrib non-free
deb-src sid main contrib non-free

需要安装的包如下:

#apt-get install postfix
#apt-get install postfix-pcre
#apt-get install dspam

1. 修改/etc/dspam/dspam.conf,修改如下

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/


2. 在/etc/postfix/master.cf最后添加


# DSPAM
127.0.0.1:10024 inet n  -       n       -        -      smtpd
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
dspam-retrain   unix    -       n       n       -       10      pipe
flags=Ru user=dspam argv=/etc/dspam/dspam-retrain $nexthop $sender $recipient


3. 在/etc/postfix/main.cf最后添加

smtpd_client_restrictions =
check_client_access pcre:/etc/postfix/dspam_filter_access
permit_auth_destination


4. 创建/etc/postfix/transport,内容如下:

spam@pymain.pymain.net dspam-retrain:spam
ham@pymain.pymain.net dspam-retrain:innocent


5. 创建/etc/postfix/dspam_filter_access,内容如下:


/./   FILTER lmtp:[127.0.0.1]:11124


6. 创建/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 user\n";
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 "$subj\n$1\n";
close(F);
} elsif (/(X-DSPAM-Signature: [a-f0-9]+)/) {
open(F, "|/usr/bin/dspam --source=error --class=$class --user $user");
print F "$subj\n$1\n";
close(F);
}
}


7. 修改/etc/dspam/dspam-retrain权限

#chmod +x /etc/dspam/dspam-retrain




参考资料:



阅读(669) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~