独学而无友,则孤陋而寡闻!
分类: BSD
2011-05-12 16:55:56
注:没有注明安装选项的按照默认选项安装
在/etc/rc.conf中加入:
mysql_enable="YES" mysql_dbdir="/home/mysqldb"启动mysql
/usr/local/etc/rc.d/mysql-server startextman安装选项
perl安装选项
extmail安装选项
安装cyrus-sasl2时需要打一个补丁,否则会导致smtp认证失败。这是freebsd升级到8.0后才有的问题,以后cyrus-sasl2更新时应该能解决这个问题吧。
下载上面的补丁,存放至/tmp/
cd /usr/ports/security/cyrus-sasl2 make patchcyrus-sasl2安装选项
postfix安装选项
You need user “postfix” added to group “mail”.选择y
Would you like to activate Postfix in /etc/mail/mailer.conf选择n
maildrop安装选项
courier-imap安装选项
apache安装选项
python安装选项
添加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 cleandspam安装选项
clamav安装选项
在/etc/rc.conf中加入
mysql_enable="YES" mysql_dbdir="/home/mysqldb"启动mysql
/usr/local/etc/rc.d/mysql-server start编辑/usr/local/www/extman/webman.cf,真对如下选项进行修改
SYS_CONFIG = /usr/local/www/extman/ SYS_LANGDIR = /usr/local/www/extman/lang SYS_TEMPLDIR = /usr/local/www/extman/html SYS_PSIZE = 50 SYS_GROUPMAIL_SENDER = admin@nio.name SYS_LANG = zh_CN SYS_DEFAULT_MAXQUOTA = 20000 SYS_DEFAULT_MAXALIAS = 100 SYS_DEFAULT_MAXUSERS = 300 SYS_DEFAULT_MAXNDQUOTA = 20000 SYS_USER_DEFAULT_QUOTA = 1000 SYS_USER_DEFAULT_NDQUOTA = 500 SYS_USER_DEFAULT_EXPIRE = 5y SYS_MYSQL_SOCKET = /tmp/mysql.sock mkdir /tmp/extman/ chown -R vmail:vmail /tmp/extman/配置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修改/usr/local/www/extmail/webmail.cf,对如下内容进行修改
SYS_CONFIG = /usr/local/www/extmail/ SYS_LANGDIR = /usr/local/www/extmail/lang SYS_TEMPLDIR = /usr/local/www/extmail/html SYS_USER_LANG = zh_CN SYS_MESSAGE_SIZE_LIMIT = 52428800 SYS_MFILTER_ON = 0 SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail SYS_MYSQL_SOCKET = /tmp/mysql.sock mkdir /tmp/extmail chown vmail:vmail /tmp/extmail/注释掉/usr/local/www/extmail/libs/Ext/Logger/File.pm的45行
#printf $fh "$time $host extmail[$$]: $msg\n", @_;否则登陆extmail后会提示
Insecure dependency in printf while running with -T switch at /usr/local/www/extmail/libs/Ext/Logger/File.pm line 45.编辑/usr/local/etc/apache22/httpd.conf,取消如下vhost的注释组。
Include etc/apache22/extra/httpd-vhosts.conf创建/usr/local/etc/apache22/Includes/extmail.conf,内容如下:
创建/usr/local/etc/apache22/Includes/extman.conf,内容如下:
编辑/etc/rc.conf,加入
apache22_enable="YES"启动apache
/usr/local/etc/rc.d/apache22 start由于在后面还要配置dspam,均要使用到mail.nio.name这个域名,因此需要使用一个跳转html,让页面自动进入extmail。
创建/usr/local/www/index.html,内容如下:
-Type" CONTENT="text/html; charset=utf-8">关闭sendmail。在/etc/rc.conf中加入
sendmail_enable="NO" sendmail_submit_enable="NO" sendmail_outbound_enable="NO" sendmail_msp_queue_enable="NO"关闭sendmail维护任务,创建/etc/periodic.conf,内容如下
daily_clean_hoststat_enable="NO" daily_status_mail_rejects_enable="NO" daily_status_include_submit_mailq="NO" daily_submit_queuerun="NO"创建/usr/local/lib/sasl2/smtpd.conf,内容如下
pwcheck_method:authdaemond log_level:3 mech_list:PLAIN LOGIN authdaemond_path:/var/run/authdaemond/socket编辑/usr/local/etc/authlib/authdaemonrc,修改如下内容
authmodulelist="authmysql" authmodulelistorig="authmysql"编辑/usr/local/etc/authlib/authmysqlrc,修改如下内容
MYSQL_SERVER localhost MYSQL_USERNAME extmail MYSQL_PASSWORD extmail MYSQL_PORT 3306 MYSQL_DATABASE extmail MYSQL_USER_TABLE mailbox MYSQL_CRYPT_PWFIELD password MYSQL_UID_FIELD uidnumber MYSQL_GID_FIELD gidnumber MYSQL_LOGIN_FIELD username MYSQL_HOME_FIELD homedir MYSQL_MAILDIR_FIELD maildir MYSQL_QUOTA_FIELD quota MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,\ CONCAT('/home/domains/',homedir), \ CONCAT('/home/domains/',maildir), \ quota, \ name \ FROM mailbox \ WHERE username = '$(local_part)@$(domain)'否则在maillog中会提示
warning: SASL authentication failure: cannot connect to Courier authdaemond: Permission denied导致smtpd认证失败
在/etc/rc.conf中添加
postfix_enable="YES" courier_authdaemond_enable="YES" /usr/local/etc/rc.d/postfix start /usr/local/etc/rc.d/courier-authdaemond start在/etc/rc.conf中添加
courier_imap_pop3d_enable="YES /usr/local/etc/rc.d/courier-imap-pop3d startextmail在freebsd8下的黑白名单功能均正常,但对发件人、收件人、标题的过滤有问题,extmail生成的maildrop规则不正确,需要如下补丁。
此外,这部分可以不加。webmail的过滤没啥用。我直接就关了。
补丁MailFilter.pm.diff内容如下:
--- MailFilter.pm.orig 2010-02-02 15:51:22.000000000 +0800 +++ MailFilter.pm 2010-02-02 16:05:30.000000000 +0800 @@ -322,15 +322,15 @@ if ($rule->{from}) { $need_decode{from} = 1; - push @statements, "(\$FROM=~/.*".slashes($rule->{from}).".*/)"; + push @statements, "(\/^FROM:\.\*".slashes($rule->{from}).".*/)"; } if ($rule->{recipient}) { $need_decode{recipient} = 1; - push @statements, "(\$TO=~/.*".slashes($rule->{recipient}).".*/)"; + push @statements, "(\/^TO:\.\*".slashes($rule->{recipient}).".*/)"; } if ($rule->{subject}) { $need_decode{subject} = 1; - push @statements, "(\$SUBJECT=~/.*".slashes($rule->{subject}).".*/)"; + push @statements, "(\/SUBJECT:\.\*".slashes($rule->{subject}).".*/)"; } if ($hasattach) { push @statements, "(/^Content-Type: *multipart\\/mixed/)"; cd /usr/local/www/extmail/libs/Ext/ patch MailFilter.pm < MailFilter.pm.diff创建数据库及用户
mysql 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/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创建/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
创建/usr/local/etc/apache22/Includes/dspam.conf
下载dspam-unicode.tar.gz,解压缩后覆盖到/usr/local/www/dspam。
修改几个cgi文件中的路径为你本机中的路径。
修改/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';修改/usr/local/etc/postfix/master.cf,加入
maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}如果邮件内容老出现如下内容:
!DSPAM:1,49179586289971925617086!将dspam的配置修改为
signatureLocation=headers注意:需要修改如下几个文件中的signatureLocation
修改后重启dspam即可。