Chinaunix首页 | 论坛 | 博客
  • 博客访问: 155497
  • 博文数量: 50
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 485
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-22 09:19
个人简介

FreeBSD,Postfix,SendMail

文章分类

全部博文(50)

文章存档

2015年(50)

我的朋友

分类: 服务器与存储

2015-01-01 20:45:14

dspam

添加dspam用户

pw group add dspam -g 1001

pw user add dspam -u 1001 -g 1001 -s /sbin/nologin -d /nonexistent

cd /usr/ports/mail/dspam

make DSPAM_OWNER=dspam DSPAM_HOME_OWNER=dspam install clean

dspam安装选项

§ SYSLOG

§ DEBUG

§ DAEMON

§ CLAMAV

§ CLAMAV_LOCAL

§ MYSQL51

§ MYSQL_COMPRESS

§ MYSQL_LOCAL

§ HASH

§ VIRT_USERS

§ LONG_USERNAMES

§ DOMAIN-SCALE

§ SENDMAIL_LDA

§ WebUI



配置cmdserver

cd /usr/local/www/extman/daemon/

chmod +x cmdserver

修改/usr/local/www/extman/daemon/cmd_plugin/freebsd-cmd

my $mysql_init开头的那行改为

my $mysql_init = '/usr/local/etc/rc.d/mysql-server';

my $dspam_init开头那行改为

my $dspam_init = '/usr/local/etc/rc.d/dspam';

启动cmdserver

/usr/local/www/extman/daemon/cmdserver --daemon


初始化dspam数据库

创建数据库及用户

mysql -u root -p

create database dspam;

grant all on dspam.* to 'dspam'@'localhost' identified by 'dspam';

创建数据库结构及初始化数据库

cd /usr/local/share/examples/dspam/mysql

mysql -udspam -pdspam -Ddspam < mysql_objects-4.1.sql

mysql -udspam -pdspam -Ddspam < virtual_users.sql


配置dspam

/usr/local/etc/dspam.conf配置如下:

Home /var/db/dspam

StorageDriver /usr/local/lib/dspam/libmysql_drv.so

DeliveryHost 127.0.0.1

DeliveryPort 10026

DeliveryIdent localhost

DeliveryProto SMTP

OnFail error

Trust root

Trust postfix

Trust dspam

Trust www

TRust vmail

Trust mail

Trust mailnull

Trust smmsp

Trust daemon

TrainingMode teft

TestConditionalTraining on

Feature whitelist

Algorithm graham burton

Tokenizer chain

PValue bcr

WebStats on

AllowOverride enableBNR

AllowOverride enableWhitelist

AllowOverride fallbackDomain

AllowOverride ignoreGroups

AllowOverride ignoreRBLLookups

AllowOverride localStore

AllowOverride makeCorpus

AllowOverride optIn

AllowOverride optOut

AllowOverride optOutClamAV

AllowOverride processorBias

AllowOverride RBLInoculate

AllowOverride showFactors

AllowOverride signatureLocation

AllowOverride spamAction

AllowOverride spamSubject

AllowOverride statisticalSedation

AllowOverride storeFragments

AllowOverride tagNonspam

AllowOverride tagSpam

AllowOverride trainPristine

AllowOverride trainingMode

AllowOverride whitelistThreshold

AllowOverride dailyQuarantineSummary

ClamAVPort 3310

ClamAVHost 127.0.0.1

ClamAVResponse accept

MySQLServer /tmp/mysql.sock

MySQLUser dspam

MySQLPass dspam

MySQLDb dspam

MySQLCompress true

MySQLReconnect true

MySQLUIDInSignature on

HashRecMax 98317

HashAutoExtend on

HashMaxExtents 0

HashExtentSize 49157

HashPctIncrease 10

HashMaxSeek 10

HashConnectionCache 10

Notifications off

LocalMX 127.0.0.1

SystemLog on

UserLog on

Opt out

ParseToHeaders on

ChangeModeOnParse on

ChangeUserOnParse full

ServerPID /var/run/dspam.pid

ServerMode auto

ServerPass.Relay1 "secret"

ServerParameters "--user dspam --deliver=innocent -d %u"

ServerIdent "localhost.localdomain"

ServerDomainSocketPath "/tmp/dspam.sock"

ClientHost /tmp/dspam.sock

ClientIdent "secret@Relay1"

ProcessorURLContext on

ProcessorBias on

StripRcptDomain off

touch /var/run/dspam.pid

chown dspam:dspam /var/run/dspam.pid

启动dspam。在/etc/rc.conf中加入

dspam_enable="YES"

/usr/local/etc/rc.d/dspam start


配置postfix支持dspam

postconf -e 'dspam_destination_recipient_limit = 1'

postconf -e 'smtpd_client_restrictions = permit_mynetworks,permit_sasl_authenticated,check_client_access pcre:/usr/local/etc/postfix/dspam_filter_access'

postconf -e 'enable_original_recipient = no' //设置always_bbc后放置出现重复邮件

postconf -e 'always_bcc = admin@nio.name' //所有邮件都转发给管理员,这样管理员可以帮助学习垃圾邮件

创建/usr/local/etc/postfix/dspam_filter_access,内容如下:

/./ FILTER dspam

postmap /usr/local/etc/postfix/dspam_filter_access

/usr/local/etc/postfix/master.cf中加入

127.0.0.1:10025 inet n - n - - smtpd

-o content_filter=

-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks

-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 smtpd_recipient_restrictions=permit_mynetworks,reject

-o mynetworks=127.0.0.0/8

-o strict_rfc821_envelopes=yes

-o smtpd_error_sleep_time=0

-o smtpd_soft_error_limit=1001

-o smtpd_hard_error_limit=1000


dspam unix - n n - - pipe

flags=DRhu user=dspam argv=/usr/local/bin/dspam

--client

--deliver=innocent,spam

--user ${recipient}

--mail-from=${sender}

修改/usr/local/etc/postfix/master.cf,修改

smtp inet n - n - - smtpd

smtp inet n - n - - smtpd

-o content_filter=lmtp:unix:/tmp/dspam.sock

重启postfix


配置apache支持dspam webui

创建/usr/local/etc/apache22/Includes/dspam.conf

ServerName dspam.nio.name

DocumentRoot /usr/local/www/dspam


AddDefaultCharset UTF-8


AllowOverride None

Options None

Order allow,deny

Allow from all

DirectoryIndex dspam.cgi

AddHandler cgi-script cgi pl

Options +ExecCGI

AuthType Basic

AuthName "DSPAM Control Center"

AuthUserFile /usr/local/www/dspam/htpasswd

Require valid-user

SuexecUserGroup dspam dspam

chown -R dspam:dspam /usr/local/www/dspam/


配置dspam webui

cd /usr/local/www/dspam/

cp configure.pl.sample configure.pl

cp default.prefs.sample default.pref

echo dspam > admins

htpasswd -c htpasswd dspam


dspam webui支持中文

下载,解压缩后覆盖到/usr/local/www/dspam

修改几个cgi文件中的路径为你本机中的路径。


修改dspam webui权限

chown -R dspam:dspam /usr/local/www/dspam/


dspam能够通过webui修改配置

cd /var/db/dspam

ln -s /usr/local/www/dspam/default.prefs ./

chmod ug+w /usr/local/www/dspam/default.prefs


extmail支持垃圾邮件报告

修改/usr/local/www/extmail/webmail.cf

SYS_SPAM_REPORT_ON = 1

SYS_SPAM_REPORT_TYPE = dspam

编辑/usr/local/www/extmail/tools/spam_report.pl,修改

my $dspam = '/usr/bin/dspamc --client --user extmail';

my $dspam = '/usr/local/bin/dspamc --client --user dspam';

配置postfixmaildrop转发

postconf -e 'virtual_transport = maildrop:'

postconf -e 'maildrop_destination_recipient_limit = 1' //maildrop不支持一次接收多个收件人

修改/usr/local/etc/postfix/master.cf,加入

maildrop unix - n n - - pipe

flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}


修改maildroprc

logfile "/home/domains/maildrop.log"

DECODER="/usr/local/www/extmail/tools/decode -v"

if ((/^(From|Sender|Return-Path):.*MAILER\-DAEMON/))

{

BADSENDER=1

}


if ( /^X-DSPAM-Result:.*Spam.*/ )

{

exception {

to "$HOME/Maildir/.Junk/."

}

}


dspam标示修改

如果邮件内容老出现如下内容:

!DSPAM:1,49179586289971925617086!

dspam的配置修改为

signatureLocation=headers

注意:需要修改如下几个文件中的signatureLocation

§ /var/db/dspam/data/local/dspam/dspam.prefs

§ /usr/local/etc/dspam.conf

§ /usr/local/www/dspam/default.prefs

修改后重启dspam即可。






阅读(1143) | 评论(0) | 转发(0) |
0

上一篇:Squid 推荐书籍

下一篇:pf.conf

给主人留下些什么吧!~~