FreeBSD下Qmail安装
[PHP]ucspi-tcp
cd /usr/ports/sysutils/ucspi-tcp
make install clean
daemontools
cd /usr/ports/sysutils/daemontools
make install clean
mkdir /var/service
chmod 755 /var/service
ee /etc/rc.conf
svscan_enable="YES"[/PHP]
reboot
验证daemontools已经正常运行:
[PHP]ps ax | grep svscan[/PHP]
[PHP]cd /usr/ports/mail/qmail
make BARRIER_BIG_TODO_PATCH=yes WITH_QMAILQUEUE_PATCH=yes BARRIER_BIG_CONCURRENCY_PATCH=yes WITH_LOCALTIME_PATCH=yes WITH_QMTPC_PATCH=yes WITH_MAILDIRQUOTA_PATCH=yes WITH_BLOCKEXEC_PATCH=yes WITH_DISCBOUNCES_PATCH=yes WITH_SPF_PATCH=yes install clean
/var/qmail/scripts/enable-qmail
cd /var/qmail/configure
./config-fast domail.com[/PHP]
打auth smtp补丁
[PHP]tar zxvf qmail-1.03.tar.gz
tar zxvf qmail-smtpd-auth-0.31.tar.gz
cp qmail-smtpd-auth-0.31/base64.* qmail-1.03
patch -d qmail-1.03 < qmail-smtpd-auth-0.31/auth.patch
cd qmail-1.03
fetch http://gadfly.shanji.com/qmail-smtpd/qmail-smtpd.c
fetch http://gadfly.shanji.com/qmail-smtpd/qmail-smtpd.patch
patch -p1 < ../qmail-103.patch
patch -p1 < ../qmailqueue-patch
patch -p1 < ../qmail-maildir++.patch
patch -p1 < ../patch-qmail-1.03-rfc2821.diff
patch -p1 < ../qmail-block-executables.patch
patch -p1 < ../qmail-discard-double-bounces.patch
patch -p1 < ../sendmail-flagf.patch
patch -p1 < ../qmail-1.03-qmtpc.patch
patch -p1 < ../qmail-date-localtime.patch
patch < qmail-smtpd.patch
ee qmail-smtpd.c[/PHP]
[PHP]将函数straynewline中的451改为553(// 当你的服务器收到无效格式的邮件时,会发送:"I am not going to accept that message at the moment,you can try again later",对方服务器收到后,几秒钟后又会发送同样的邮件给你,造成多次的重复。改为553后,你的服务器将直接发送:"I am not going to accept that message,don't try sending it again.",告诉对方的服务器不要再发这封无效的信件。)
void die_alarm() { out("451 超时. (#4.4.2)/r/n"); flush(); _exit(1); }
void die_nomem() { out("421 内存溢出. (#4.3.0)/r/n"); flush(); _exit(1); }
void die_control() { out("421 无法读取控制文件. (#4.3.0)/r/n"); flush(); _exit(1); }
void die_ipme() { out("421 无法判断发信IP地址. (#4.3.0)/r/n"); flush(); _exit(1); }
void straynewline() { out("451 如有疑问请发邮件到: xiwu518@163.com/r/n"); flush(); _exit(1); }
void err_bmf() { out("553 对不起您的邮件地址在我的黑名单里. (#5.7.1)/r/n"); }
void err_nogateway() { out("553 对不起,您所发送的邮件不在服务器允许的范围内. (#5.7.1)/r/n"); }
void err_unimpl() { out("502 命令执行失败. (#5.5.1)/r/n"); }
void err_syntax() { out("555 语法错误. (#5.5.4)/r/n"); }
out("214 WelCome To: http://www.domail.com/r/n");
out("354 继续./r/n");
if (databytes) if (!bytestooverflow) { out("552 对不起,邮件大小超出服务器允许接受的范围. (#5.3.4)/r/n"); return; }[/PHP]
[PHP]make qmail-smtpd
cd /var/qmail/bin
mv qmail-smtpd qmail-smtpd.auth
cd -
cp qmail-smtpd /var/qmail/bin/qmail-smtpd
mkdir /var/log/qmail
cd /var/log/qmail
mkdir qmail-send qmail-smtpd qmail-pop3d
chown -R qmaill:wheel /var/log/qmail
chmod -R 750 /var/log/qmail
mkdir /var/qmail/supervise
cd /var/qmail/supervise
mkdir -p qmail-smtpd/log qmail-send/log qmail-pop3d/log
chmod +t qmail-smtpd qmail-send qmail-pop3d
ln -s /var/qmail/supervise/* /var/service/[/PHP]
maildrop
[PHP]tar -xjvf maildrop-1.8.1.tar.bz2
cd maildrop-1.8.1
./configure --prefix=/usr/local --exec-prefix=/usr/local --enable-maildrop-uid=root --enable-maildrop-gid=vchkpw --enable-maildirquota
make
make install-strip
make install-man[/PHP]
qmail启动脚本
[PHP]ee /var/qmail/supervise/qmail-pop3d/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec tcpserver -H -R -v -c100 0 110 qmail-popup domail.com /
/home/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-pop3d/log/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-pop3d 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-smtpd/run
#!/bin/sh
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 40000000 /
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" /
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /
/usr/local/bin/rblsmtpd /
-r cblplus.anti-spam.org.cn /
-r relays.ordb.org /
/var/qmail/bin/qmail-smtpd /
/home/vpopmail/bin/vchkpw /usr/bin/true 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-smtpd/log/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-smtpd 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-send/run
#!/bin/sh
exec /var/qmail/rc[/PHP]
[PHP]ee /var/qmail/supervise/qmail-send/log/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-send 2>&1[/PHP]
[PHP]ee /var/qmail/rc
#!/bin/sh
exec env - PATH="/var/qmail/bin:$PATH" /
qmail-start "`cat /var/qmail/control/defaultdelivery`"[/PHP]
[PHP]ee /usr/bin/qmailctl
#!/bin/sh
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`/usr/bin/id -u qmaild`
NOFILESGID=`/usr/bin/id -g qmaild`
case "$1" in
start)
echo "Starting qmail..."
echo ""
if svok /var/service/qmail-send ; then
svc -u /var/service/qmail-send /var/service/qmail-send/log
echo "Starting qmail-send"
else
echo "qmail-send supervise not running"
fi
if svok /var/service/qmail-smtpd ; then
svc -u /var/service/qmail-smtpd /var/service/qmail-smtpd/log
echo "Starting qmail-smtpd"
else
echo "qmail-smtpd supervise not running"
fi
if svok /var/service/qmail-pop3d ; then
svc -u /var/service/qmail-pop3d /var/service/qmail-pop3d/log
echo "Starting qmail-pop3d"
else
echo "qmail-pop3d supervise not running"
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo "Stopping qmail..."
echo ""
echo " qmail-smtpd"
svc -d /var/service/qmail-smtpd /var/service/qmail-smtpd/log
echo " qmail-send"
svc -d /var/service/qmail-send /var/service/qmail-send/log
echo " qmail-pop3d"
svc -d /var/service/qmail-pop3d /var/service/qmail-pop3d/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /var/service/qmail-send
svstat /var/service/qmail-send/log
svstat /var/service/qmail-smtpd
svstat /var/service/qmail-smtpd/log
svstat /var/service/qmail-pop3d
svstat /var/service/qmail-pop3d/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /var/service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /var/service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /var/service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /var/service/qmail-smtpd
echo "Pausing qmail-pop3d"
svc -p /var/service/qmail-pop3d
;;
cont)
echo "Continuing qmail-send"
svc -c /var/service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /var/service/qmail-smtpd
echo "Continuing qmail-pop3d"
svc -c /var/service/qmail-pop3d
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /var/service/qmail-smtpd /var/service/qmail-smtpd/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /var/service/qmail-send /var/service/qmail-send/log
echo "* Sending qmail-pop3d SIGTERM and restarting."
svc -t /var/service/qmail-pop3d /var/service/qmail-pop3d/log
echo "* Restarting qmail-smtpd."
svc -u /var/service/qmail-smtpd /var/service/qmail-smtpd/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat < stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0
[/PHP]
[PHP]chmod 755 /var/qmail/rc /usr/bin/qmailctl
chmod 751 /var/qmail/supervise/qmail-pop3d/run
chmod 751 /var/qmail/supervise/qmail-pop3d/log/run
chmod 751 /var/qmail/supervise/qmail-smtpd/run
chmod 751 /var/qmail/supervise/qmail-smtpd/log/run
chmod 751 /var/qmail/supervise/qmail-send/run
chmod 751 /var/qmail/supervise/qmail-send/log/run
echo ./Maildir > /var/qmail/control/defaultdelivery
echo 255 > /var/qmail/control/concurrencyremote
chmod 644 /var/qmail/control/concurrencyremote
echo 30 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
ln -s /usr/bin/qmailctl /usr/local/etc/rc.d/qmail.sh
echo '127.0.0.1:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
qmailctl cdb[/PHP]
[PHP]设置管理员的邮箱地址。发往root/postmaster/mailer-daemon地址的邮件将会由定义的管理员邮箱接收。
cd /var/qmail/alias
echo "webmaster@domail.com" > .qmail-postmaster
echo "webmaster@domail.com" > .qmail-mailer-daemon
echo "webmaster@domail.com" > .qmail-root
chmod 644 /var/qmail/alias/.qmail*
echo postmaster > /var/qmail/control/bouncefrom // 投递失败发送者
echo domail.com > /var/qmail/control/helohost // 主机名
echo '# reject containing invalid characters, brackets or multiple @' >> /var/qmail/control/badmailto
echo '[!%#:/*/^]' >> /var/qmail/control/badmailto
echo '[/(/)]' >> /var/qmail/control/badmailto
echo '[/{/}]' >> /var/qmail/control/badmailto
echo '@.*@' >> /var/qmail/control/badmailto
echo 8192000 > /var/qmail/control/databytes // 接收邮件的最大容量 (0=无限制)
echo 300 > /var/qmail/control/concurrencylocal // 本地同时投递邮件的数目
mv /usr/sbin/sendmail /usr/sbin/sendmail.old
chmod 0 /usr/sbin/sendmail.old
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
qmailctl start
qmailctl stat[/PHP]
应该看到类似的信息
[PHP]/service/qmail-send: up (pid 29956) 2 seconds
/service/qmail-send/log: up (pid 29960) 2 seconds
/service/qmail-smtpd: up (pid 29963) 2 seconds
/service/qmail-smtpd/log: up (pid 29968) 2 seconds
/service/qmail-pop3d: up (pid 29971) 2 seconds
/service/qmail-pop3d/log: up (pid 29972) 2 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0[/PHP]
vpopmail
[PHP]mkdir -p /home/vpopmail/etc
pw groupadd vchkpw -g 89
pw useradd vpopmail -u 89 -g 89 -d /home/vpopmail -s /nonexistent
chown vpopmail:vchkpw /home/vpopmail/etc
echo "localhost|0|mail|passwd|mailserver" > /home/vpopmail/etc/vpopmail.mysql
chown vpopmail:vchkpw /home/vpopmail/etc/vpopmail.mysql
chmod 640 /home/vpopmail/etc/vpopmail.mysql
在MySQL里添加vpopmail的帐号
mysql -uroot -p
create database emailserver;
grant select,insert,update,delete,create,drop on mailserver.* to mail@localhost identified by "passwd";
flush privileges;
quit
tar zxvf vpopmail-5.4.10.tar.gz
cd vpopmail-5.4.10
./configure --enable-incdir=/usr/include/mysql --enable-libdir=/usr/lib/mysql --enable-logging=p --disable-passwd --disable-domain-quotas --enable-auth-module=mysql --enable-auth-logging --enable-sql-logging --disable-mysql-limits --enable-many-domains --disable-clear-passwd --enable-sqwebmail-pass --enable-valias
make
make install-strip[/PHP]
[PHP]设置默认域
echo "domail.com" > /home/vpopmail/etc/defaultdomain
添加域
/home/vpopmail/bin/vadddomain domail.com passwd
添加用户
/home/vpopmail/bin/vadduser -q 52428800S webmaster@domail.com passwd
会自动往表vpopmail中添加用户数据,用户添加到默认的域里面。如果要添加到其他的虚拟域,用户名要带域名,如果不成功的话,则必须先删除创建的域,./vdeldomain 域名 不要使用手工操作mysql删除域和用户帐号(除非你特别熟悉),否则会引起系统帐户的紊乱
设置邮箱容量达到90%的警告信息
ee /home/vpopmail/domains/.quotawarn.msg
邮件发送人: 管理员
邮件地址: webmaster@domail.com
邮件收件人: 邮箱用户
邮件主题: 邮箱空间警告
邮件协议版本: 1.0
邮件类型: text/html; charset=gb2312
邮件编码: base64
您的邮箱空间已经达到90%.如果想继续使用,请删除一些信件.
如果需要帮助,请联系管理员:
邮件地址 : webmaster@domail.com
设置邮箱已满的警告信息
ee /home/vpopmail/domains/.over-quota.msg
"因为用户的邮箱空间已满,所以邮件被拒收."
touch /home/vpopmail/domains/domail.com/.qmailadmin-limits
ee /home/vpopmail/domains/domail.com/.qmailadmin-limits
内容为:
quota 1000 #域总容量不能超过1000M
maxmsgcount 1000 #域邮箱用户最多1000个
chmod 600 .qmailadmin-limits
[/PHP]
autorespond
[PHP]cd /usr/ports/mail/autorespond
make install clean[/PHP]
ezmlm
[PHP]tar -xvzf ezmlm-0.53.tar.gz
tar -xvzf ezmlm-idx-0.42.tar.gz
cp -rf ezmlm-idx-0.42/* ezmlm-0.53/
cd ezmlm-0.53
patch < idx.patch
chmod u+x makelang
make
make man
make ch_GB
make setup[/PHP]
qmailadmin
[PHP]tar -xvzf qmailadmin-1.2.7.tar.gz
cd qmailadmin-1.2.7
./configure --enable-htmldir=/usr/local/www --enable-cgibindir=/usr/local/www/cgi-bin --enable-vpopuser=vpopmail --enable-autoresponder-bin=/usr/local/bin --enable-ezmlmdir=/usr/local/bin/ezmlm --enable-maxusersperpage=20 --enable-maxaliasesperpage=20 --enable-modify-quota --disable-ezmlm-mysql --enable-domain-autofill
make
make install-strip
cd /usr/local/share/qmailadmin/lang
mv en en.bak
cp zh-cn en[/PHP]
tnef
[PHP]cd /usr/ports/converters/tnef
make install clean[/PHP]
qmail-remove
[PHP]cd /usr/ports/mail/qmail-remove
make install clean
查看队列
/usr/local/sbin/qmail-remove -q /var/qmail/queue
删除队列
/usr/local/sbin/qmail-remove -r[/PHP]
courier-authlib
[PHP]tar -xjvf courier-authlib-0.56.tar.bz2
cd courier-authlib-0.56
./configure --without-authpam --without-authldap --without-authpwd --without-authmysql --without-authpgsql --without-authshadow --without-authuserdb --without-authcustom --without-authcram --with-authvchkpw
make
make install
make install-configure
ee /usr/local/etc/authlib/authdaemonrc
authmodulelist="authvchkpw"
authmodulelistorig="authvchkpw"
daemons=2
cp /usr/local/sbin/authdaemond /usr/local/etc/rc.d/authdaemond.sh
chmod 755 /usr/local/etc/rc.d/authdaemond.sh
mkdir -p /var/lock/subsys/
/usr/local/etc/rc.d/authdaemond.sh start[/PHP]
查看进程
[PHP]ps -aef |grep authlib[/PHP]
测试
[PHP]/usr/local/sbin/authtest webmaster@domail.com passwd[/PHP]
courier-imap
[PHP]cd courier-imap-4.0.3
./configure --prefix=/usr/local --exec-prefix=/usr/local --without-authdaemon --with-authvchkpw --without-authldap --disable-root-check --with-ssl CPPFLAGS=-I/usr/local/include CFLAGS="-DHAVE_OPEN_SMTP_RELAY -DHAVE_VLOGAUTH"
make
make install-strip
cp courier-imap.sysvinit /usr/local/etc/rc.d/courier-imap.sh
chmod 755 /usr/local/etc/rc.d/courier-imap.sh
mkdir -p /var/lock/subsys
cd /usr/local/etc
cp imapd.dist imapd
cp imapd-ssl.dist imapd-ssl
ee imapd.cnf
CN=domail.com
emailAddress=postmaster@domail.com
/usr/local/sbin/mkimapdcert
ee imapd
IMAPDSTART=YES
ee imapd-ssl
IMAPDSSLSTART=YES
/usr/local/etc/rc.d/courier-imap.sh start[/PHP]
SpamAssassin
[PHP]cd /usr/ports/devel/p5-Time-HiRes
make install clean
cd /usr/ports/dns/p5-Net-DNS
make install clean
cd /usr/ports/textproc/p5-PodParser
make install clean
cd /usr/ports/textproc/p5-Parse-Syslog
make install clean
cd /usr/ports/math/p5-Statistics-Distributions
make install clean
tar xzf Mail-SpamAssassin-3.0.4.tar.gz
cd Mail-SpamAssassin-3.0.4
perl Makefile.PL
make
make install
cd /etc/mail/spamassassin
env LANG=C ee local.cf
required_score 6.0
rewrite_header Subject ****这是一封垃圾邮件****
report_safe 1
use_bayes 1
skip_rbl_checks 0
ok_languages zh en ko
ok_locales en ko zh
score HEAD_ILLEGAL_CHARS 0
score SUBJ_ILLEGAL_CHARS 0
score DATE_IN_PAST_03_06 0
score UPPERCASE_25_50 0
score UPPERCASE_50_75 0
score UPPERCASE_75_100 0
score X_MSMAIL_PRIORITY_HIGH 0
score X_PRIORITY_HIGH 0
score TO_TXT 100
score RATWARE_HASH_2 100
score RATWARE_HASH_2_V2 100
score BAYES_99 0.1
score BAYES_80 0.1
score BAYES_60 0.1
score FROM_ILLEGAL_CHARS 0.1
score MIME_BASE64_TEXT 0.1
score NO_RDNS_DOTCOM_HELO 0.1
score CHINA_HEADER 0.1
score NO_REAL_NAME 0.2
score HTML_MESSAGE 0.2
score MIME_HTML_ONLY 0.2
score MIME_HTML_ONLY_MULTI 0.2
score FORGED_MUA_OUTLOOK 0.2
score FORGED_HOTMAIL_RCVD 0.2
score FORGED_OUTLOOK_TAGS 0.2
score MAILTO_TO_SPAM_ADDR 0.2[/PHP]
下载新的垃圾邮件地址列表文件
[PHP]cd /usr/local/share/spamassassin
fetch http://anti-spam.org.cn/rules/sa/55_diy_score.cf[/PHP]
建立SpamAssassin的学习系统
[PHP]/usr/local/bin/sa-learn --rebuild -D -p user_prefs[/PHP]
查看自学习的数据信息
[PHP]/usr/local/bin/sa-learn --dump all[/PHP]
qmail与SpamAssassin结合
[PHP]cd Mail-SpamAssassin-3.0.4/spamc
cc -O -o qmail-spamc qmail-spamc.c
install -m 755 qmail-spamc /var/qmail/bin
ln -s /var/qmail/bin/qmail-queue /usr/bin/qmail-queue[/PHP]
启动spamd
[PHP]/usr/local/bin/spamd --daemonize --pidfile /var/run/spamd.pid[/PHP]
[PHP]ee /etc/rc.local
/usr/local/bin/spamd --daemonize --pidfile /var/run/spamd.pid[/PHP]
qmail-scanner
[PHP]pw groupadd qscand -g 90
pw useradd qscand -c "Qmail-Scanner Account" -u 90 -g 90 -s /bin/false
tar zxvf qmail-scanner-1.25.tgz
cd qmail-scanner-1.25
./configure --admin webmaster --domain domail.com --notify sender,admin --local-domains domail.com --archive yes --add-dscr-hdrs yes --redundant yes --debug yes --unzip yes --scanners clamscan,fast_spamassassin --install[/PHP]
应该有类似提示
[PHP]perlscanner: generate new DB file from /var/spool/qmailscan/quarantine-attachments.txt
perlscanner: total of 9 entries[/PHP]
[PHP]chown -R qscand:qscand /var/spool/qmailscan
ee /etc/tcp.smtp
127.0.0.1.:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
:allow,QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"[/PHP]
[PHP]ee /var/qmail/bin/qmail-scanner-queue.pl
my $V_FROMNAME='管理员';
my $clamscan_options="-r -m --mbox --unzip --unrar --unzoo --lha --disable-summary --max-recursion=10 --max-space=1000000";
my $spamc_subject='疑为垃圾邮件';
qmailctl cdb
qmailctl stop
qmailctl start
qmailctl stat[/PHP]
设置邮件服务器过滤掉一些病毒附件(注:添加文件格式时要手动输入,空格用TAB键补齐!!!)
[PHP]ee /var/spool/qmailscan/quarantine-attachments.txt
.exe 0 系统不允许接收EXE格式的附件
.vbs 0 系统不允许接收VBS格式的附件
.lnk 0 系统不允许接收LNK格式的附件
.scr 0 系统不允许接收SCR格式的附件
.wsh 0 系统不允许接收WSH格式的附件
.hta 0 系统不允许接收HTA格式的附件
.pif 0 系统不允许接收PIF格式的附件
.cpl 0 系统不允许接收CPL格式的附件
.sql 0 系统不允许接收SQL格式的附件
.php 0 系统不允许接收PHP格式的附件
.asp 0 系统不允许接收ASP格式的附件
.com 0 系统不允许接收COM格式的附件
.bat 0 系统不允许接收BAT格式的附件[/PHP]
编辑完成后,运行
[PHP]/var/qmail/bin/qmail-scanner-queue.pl -g[/PHP] 即时生效。
用qmail封mail from
[PHP]ee /var/qmail/control/badmailfrom
这个控制文件实现拒收邮件功能的,每一个地址要单独一行。而且,不用重起qmail就能生效。例如
rpnai@yahoo.com -----限制一个特定的用户
@sina.com -----限制整个域中的邮件[/PHP]
注:Qmail启动脚本有点问题(启动时会提示[PHP]qmail-**** supervise not running[/PHP] ),但是不影响使用。有心有力的朋友帮忙修改一下,谢谢!因为使用ports牵掣到安装目录等问题,所以部分程序采用手动编译。
[PHP]ucspi-tcp
cd /usr/ports/sysutils/ucspi-tcp
make install clean
daemontools
cd /usr/ports/sysutils/daemontools
make install clean
mkdir /var/service
chmod 755 /var/service
ee /etc/rc.conf
svscan_enable="YES"[/PHP]
reboot
验证daemontools已经正常运行:
[PHP]ps ax | grep svscan[/PHP]
[PHP]cd /usr/ports/mail/qmail
make BARRIER_BIG_TODO_PATCH=yes WITH_QMAILQUEUE_PATCH=yes BARRIER_BIG_CONCURRENCY_PATCH=yes WITH_LOCALTIME_PATCH=yes WITH_QMTPC_PATCH=yes WITH_MAILDIRQUOTA_PATCH=yes WITH_BLOCKEXEC_PATCH=yes WITH_DISCBOUNCES_PATCH=yes WITH_SPF_PATCH=yes install clean
/var/qmail/scripts/enable-qmail
cd /var/qmail/configure
./config-fast domail.com[/PHP]
打auth smtp补丁
[PHP]tar zxvf qmail-1.03.tar.gz
tar zxvf qmail-smtpd-auth-0.31.tar.gz
cp qmail-smtpd-auth-0.31/base64.* qmail-1.03
patch -d qmail-1.03 < qmail-smtpd-auth-0.31/auth.patch
cd qmail-1.03
fetch http://gadfly.shanji.com/qmail-smtpd/qmail-smtpd.c
fetch http://gadfly.shanji.com/qmail-smtpd/qmail-smtpd.patch
patch -p1 < ../qmail-103.patch
patch -p1 < ../qmailqueue-patch
patch -p1 < ../qmail-maildir++.patch
patch -p1 < ../patch-qmail-1.03-rfc2821.diff
patch -p1 < ../qmail-block-executables.patch
patch -p1 < ../qmail-discard-double-bounces.patch
patch -p1 < ../sendmail-flagf.patch
patch -p1 < ../qmail-1.03-qmtpc.patch
patch -p1 < ../qmail-date-localtime.patch
patch < qmail-smtpd.patch
ee qmail-smtpd.c[/PHP]
[PHP]将函数straynewline中的451改为553(// 当你的服务器收到无效格式的邮件时,会发送:"I am not going to accept that message at the moment,you can try again later",对方服务器收到后,几秒钟后又会发送同样的邮件给你,造成多次的重复。改为553后,你的服务器将直接发送:"I am not going to accept that message,don't try sending it again.",告诉对方的服务器不要再发这封无效的信件。)
void die_alarm() { out("451 超时. (#4.4.2)/r/n"); flush(); _exit(1); }
void die_nomem() { out("421 内存溢出. (#4.3.0)/r/n"); flush(); _exit(1); }
void die_control() { out("421 无法读取控制文件. (#4.3.0)/r/n"); flush(); _exit(1); }
void die_ipme() { out("421 无法判断发信IP地址. (#4.3.0)/r/n"); flush(); _exit(1); }
void straynewline() { out("451 如有疑问请发邮件到: xiwu518@163.com/r/n"); flush(); _exit(1); }
void err_bmf() { out("553 对不起您的邮件地址在我的黑名单里. (#5.7.1)/r/n"); }
void err_nogateway() { out("553 对不起,您所发送的邮件不在服务器允许的范围内. (#5.7.1)/r/n"); }
void err_unimpl() { out("502 命令执行失败. (#5.5.1)/r/n"); }
void err_syntax() { out("555 语法错误. (#5.5.4)/r/n"); }
out("214 WelCome To: http://www.domail.com/r/n");
out("354 继续./r/n");
if (databytes) if (!bytestooverflow) { out("552 对不起,邮件大小超出服务器允许接受的范围. (#5.3.4)/r/n"); return; }[/PHP]
[PHP]make qmail-smtpd
cd /var/qmail/bin
mv qmail-smtpd qmail-smtpd.auth
cd -
cp qmail-smtpd /var/qmail/bin/qmail-smtpd
mkdir /var/log/qmail
cd /var/log/qmail
mkdir qmail-send qmail-smtpd qmail-pop3d
chown -R qmaill:wheel /var/log/qmail
chmod -R 750 /var/log/qmail
mkdir /var/qmail/supervise
cd /var/qmail/supervise
mkdir -p qmail-smtpd/log qmail-send/log qmail-pop3d/log
chmod +t qmail-smtpd qmail-send qmail-pop3d
ln -s /var/qmail/supervise/* /var/service/[/PHP]
maildrop
[PHP]tar -xjvf maildrop-1.8.1.tar.bz2
cd maildrop-1.8.1
./configure --prefix=/usr/local --exec-prefix=/usr/local --enable-maildrop-uid=root --enable-maildrop-gid=vchkpw --enable-maildirquota
make
make install-strip
make install-man[/PHP]
qmail启动脚本
[PHP]ee /var/qmail/supervise/qmail-pop3d/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec tcpserver -H -R -v -c100 0 110 qmail-popup domail.com /
/home/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-pop3d/log/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-pop3d 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-smtpd/run
#!/bin/sh
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 40000000 /
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" /
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /
/usr/local/bin/rblsmtpd /
-r cblplus.anti-spam.org.cn /
-r relays.ordb.org /
/var/qmail/bin/qmail-smtpd /
/home/vpopmail/bin/vchkpw /usr/bin/true 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-smtpd/log/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-smtpd 2>&1[/PHP]
[PHP]ee /var/qmail/supervise/qmail-send/run
#!/bin/sh
exec /var/qmail/rc[/PHP]
[PHP]ee /var/qmail/supervise/qmail-send/log/run
#!/bin/sh
PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin
export PATH
exec setuidgid qmaill multilog t s100000 n20 /var/log/qmail/qmail-send 2>&1[/PHP]
[PHP]ee /var/qmail/rc
#!/bin/sh
exec env - PATH="/var/qmail/bin:$PATH" /
qmail-start "`cat /var/qmail/control/defaultdelivery`"[/PHP]
[PHP]ee /usr/bin/qmailctl
#!/bin/sh
# description: the qmail MTA
PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
QMAILDUID=`/usr/bin/id -u qmaild`
NOFILESGID=`/usr/bin/id -g qmaild`
case "$1" in
start)
echo "Starting qmail..."
echo ""
if svok /var/service/qmail-send ; then
svc -u /var/service/qmail-send /var/service/qmail-send/log
echo "Starting qmail-send"
else
echo "qmail-send supervise not running"
fi
if svok /var/service/qmail-smtpd ; then
svc -u /var/service/qmail-smtpd /var/service/qmail-smtpd/log
echo "Starting qmail-smtpd"
else
echo "qmail-smtpd supervise not running"
fi
if svok /var/service/qmail-pop3d ; then
svc -u /var/service/qmail-pop3d /var/service/qmail-pop3d/log
echo "Starting qmail-pop3d"
else
echo "qmail-pop3d supervise not running"
fi
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo "Stopping qmail..."
echo ""
echo " qmail-smtpd"
svc -d /var/service/qmail-smtpd /var/service/qmail-smtpd/log
echo " qmail-send"
svc -d /var/service/qmail-send /var/service/qmail-send/log
echo " qmail-pop3d"
svc -d /var/service/qmail-pop3d /var/service/qmail-pop3d/log
if [ -f /var/lock/subsys/qmail ]; then
rm /var/lock/subsys/qmail
fi
;;
stat)
svstat /var/service/qmail-send
svstat /var/service/qmail-send/log
svstat /var/service/qmail-smtpd
svstat /var/service/qmail-smtpd/log
svstat /var/service/qmail-pop3d
svstat /var/service/qmail-pop3d/log
qmail-qstat
;;
doqueue|alrm|flush)
echo "Flushing timeout table and sending ALRM signal to qmail-send."
/var/qmail/bin/qmail-tcpok
svc -a /var/service/qmail-send
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
echo "Sending HUP signal to qmail-send."
svc -h /var/service/qmail-send
;;
pause)
echo "Pausing qmail-send"
svc -p /var/service/qmail-send
echo "Pausing qmail-smtpd"
svc -p /var/service/qmail-smtpd
echo "Pausing qmail-pop3d"
svc -p /var/service/qmail-pop3d
;;
cont)
echo "Continuing qmail-send"
svc -c /var/service/qmail-send
echo "Continuing qmail-smtpd"
svc -c /var/service/qmail-smtpd
echo "Continuing qmail-pop3d"
svc -c /var/service/qmail-pop3d
;;
restart)
echo "Restarting qmail:"
echo "* Stopping qmail-smtpd."
svc -d /var/service/qmail-smtpd /var/service/qmail-smtpd/log
echo "* Sending qmail-send SIGTERM and restarting."
svc -t /var/service/qmail-send /var/service/qmail-send/log
echo "* Sending qmail-pop3d SIGTERM and restarting."
svc -t /var/service/qmail-pop3d /var/service/qmail-pop3d/log
echo "* Restarting qmail-smtpd."
svc -u /var/service/qmail-smtpd /var/service/qmail-smtpd/log
;;
cdb)
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
chmod 644 /etc/tcp.smtp.cdb
echo "Reloaded /etc/tcp.smtp."
;;
help)
cat < stop -- stops mail service (smtp connections refused, nothing goes out)
start -- starts mail service (smtp connection accepted, mail can go out)
pause -- temporarily stops mail service (connections accepted, nothing leaves)
cont -- continues paused mail service
stat -- displays status of mail service
cdb -- rebuild the tcpserver cdb file for smtp
restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it
doqueue -- schedules queued messages for immediate delivery
reload -- sends qmail-send HUP, rereading locals and virtualdomains
queue -- shows status of queue
alrm -- same as doqueue
flush -- same as doqueue
hup -- same as reload
HELP
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}"
exit 1
;;
esac
exit 0
[/PHP]
[PHP]chmod 755 /var/qmail/rc /usr/bin/qmailctl
chmod 751 /var/qmail/supervise/qmail-pop3d/run
chmod 751 /var/qmail/supervise/qmail-pop3d/log/run
chmod 751 /var/qmail/supervise/qmail-smtpd/run
chmod 751 /var/qmail/supervise/qmail-smtpd/log/run
chmod 751 /var/qmail/supervise/qmail-send/run
chmod 751 /var/qmail/supervise/qmail-send/log/run
echo ./Maildir > /var/qmail/control/defaultdelivery
echo 255 > /var/qmail/control/concurrencyremote
chmod 644 /var/qmail/control/concurrencyremote
echo 30 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
ln -s /usr/bin/qmailctl /usr/local/etc/rc.d/qmail.sh
echo '127.0.0.1:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
qmailctl cdb[/PHP]
[PHP]设置管理员的邮箱地址。发往root/postmaster/mailer-daemon地址的邮件将会由定义的管理员邮箱接收。
cd /var/qmail/alias
echo "webmaster@domail.com" > .qmail-postmaster
echo "webmaster@domail.com" > .qmail-mailer-daemon
echo "webmaster@domail.com" > .qmail-root
chmod 644 /var/qmail/alias/.qmail*
echo postmaster > /var/qmail/control/bouncefrom // 投递失败发送者
echo domail.com > /var/qmail/control/helohost // 主机名
echo '# reject containing invalid characters, brackets or multiple @' >> /var/qmail/control/badmailto
echo '[!%#:/*/^]' >> /var/qmail/control/badmailto
echo '[/(/)]' >> /var/qmail/control/badmailto
echo '[/{/}]' >> /var/qmail/control/badmailto
echo '@.*@' >> /var/qmail/control/badmailto
echo 8192000 > /var/qmail/control/databytes // 接收邮件的最大容量 (0=无限制)
echo 300 > /var/qmail/control/concurrencylocal // 本地同时投递邮件的数目
mv /usr/sbin/sendmail /usr/sbin/sendmail.old
chmod 0 /usr/sbin/sendmail.old
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
qmailctl start
qmailctl stat[/PHP]
应该看到类似的信息
[PHP]/service/qmail-send: up (pid 29956) 2 seconds
/service/qmail-send/log: up (pid 29960) 2 seconds
/service/qmail-smtpd: up (pid 29963) 2 seconds
/service/qmail-smtpd/log: up (pid 29968) 2 seconds
/service/qmail-pop3d: up (pid 29971) 2 seconds
/service/qmail-pop3d/log: up (pid 29972) 2 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0[/PHP]
vpopmail
[PHP]mkdir -p /home/vpopmail/etc
pw groupadd vchkpw -g 89
pw useradd vpopmail -u 89 -g 89 -d /home/vpopmail -s /nonexistent
chown vpopmail:vchkpw /home/vpopmail/etc
echo "localhost|0|mail|passwd|mailserver" > /home/vpopmail/etc/vpopmail.mysql
chown vpopmail:vchkpw /home/vpopmail/etc/vpopmail.mysql
chmod 640 /home/vpopmail/etc/vpopmail.mysql
在MySQL里添加vpopmail的帐号
mysql -uroot -p
create database emailserver;
grant select,insert,update,delete,create,drop on mailserver.* to mail@localhost identified by "passwd";
flush privileges;
quit
tar zxvf vpopmail-5.4.10.tar.gz
cd vpopmail-5.4.10
./configure --enable-incdir=/usr/include/mysql --enable-libdir=/usr/lib/mysql --enable-logging=p --disable-passwd --disable-domain-quotas --enable-auth-module=mysql --enable-auth-logging --enable-sql-logging --disable-mysql-limits --enable-many-domains --disable-clear-passwd --enable-sqwebmail-pass --enable-valias
make
make install-strip[/PHP]
[PHP]设置默认域
echo "domail.com" > /home/vpopmail/etc/defaultdomain
添加域
/home/vpopmail/bin/vadddomain domail.com passwd
添加用户
/home/vpopmail/bin/vadduser -q 52428800S webmaster@domail.com passwd
会自动往表vpopmail中添加用户数据,用户添加到默认的域里面。如果要添加到其他的虚拟域,用户名要带域名,如果不成功的话,则必须先删除创建的域,./vdeldomain 域名 不要使用手工操作mysql删除域和用户帐号(除非你特别熟悉),否则会引起系统帐户的紊乱
设置邮箱容量达到90%的警告信息
ee /home/vpopmail/domains/.quotawarn.msg
邮件发送人: 管理员
邮件地址: webmaster@domail.com
邮件收件人: 邮箱用户
邮件主题: 邮箱空间警告
邮件协议版本: 1.0
邮件类型: text/html; charset=gb2312
邮件编码: base64
您的邮箱空间已经达到90%.如果想继续使用,请删除一些信件.
如果需要帮助,请联系管理员:
邮件地址 : webmaster@domail.com
设置邮箱已满的警告信息
ee /home/vpopmail/domains/.over-quota.msg
"因为用户的邮箱空间已满,所以邮件被拒收."
touch /home/vpopmail/domains/domail.com/.qmailadmin-limits
ee /home/vpopmail/domains/domail.com/.qmailadmin-limits
内容为:
quota 1000 #域总容量不能超过1000M
maxmsgcount 1000 #域邮箱用户最多1000个
chmod 600 .qmailadmin-limits
[/PHP]
autorespond
[PHP]cd /usr/ports/mail/autorespond
make install clean[/PHP]
ezmlm
[PHP]tar -xvzf ezmlm-0.53.tar.gz
tar -xvzf ezmlm-idx-0.42.tar.gz
cp -rf ezmlm-idx-0.42/* ezmlm-0.53/
cd ezmlm-0.53
patch < idx.patch
chmod u+x makelang
make
make man
make ch_GB
make setup[/PHP]
qmailadmin
[PHP]tar -xvzf qmailadmin-1.2.7.tar.gz
cd qmailadmin-1.2.7
./configure --enable-htmldir=/usr/local/www --enable-cgibindir=/usr/local/www/cgi-bin --enable-vpopuser=vpopmail --enable-autoresponder-bin=/usr/local/bin --enable-ezmlmdir=/usr/local/bin/ezmlm --enable-maxusersperpage=20 --enable-maxaliasesperpage=20 --enable-modify-quota --disable-ezmlm-mysql --enable-domain-autofill
make
make install-strip
cd /usr/local/share/qmailadmin/lang
mv en en.bak
cp zh-cn en[/PHP]
tnef
[PHP]cd /usr/ports/converters/tnef
make install clean[/PHP]
qmail-remove
[PHP]cd /usr/ports/mail/qmail-remove
make install clean
查看队列
/usr/local/sbin/qmail-remove -q /var/qmail/queue
删除队列
/usr/local/sbin/qmail-remove -r[/PHP]
courier-authlib
[PHP]tar -xjvf courier-authlib-0.56.tar.bz2
cd courier-authlib-0.56
./configure --without-authpam --without-authldap --without-authpwd --without-authmysql --without-authpgsql --without-authshadow --without-authuserdb --without-authcustom --without-authcram --with-authvchkpw
make
make install
make install-configure
ee /usr/local/etc/authlib/authdaemonrc
authmodulelist="authvchkpw"
authmodulelistorig="authvchkpw"
daemons=2
cp /usr/local/sbin/authdaemond /usr/local/etc/rc.d/authdaemond.sh
chmod 755 /usr/local/etc/rc.d/authdaemond.sh
mkdir -p /var/lock/subsys/
/usr/local/etc/rc.d/authdaemond.sh start[/PHP]
查看进程
[PHP]ps -aef |grep authlib[/PHP]
测试
[PHP]/usr/local/sbin/authtest webmaster@domail.com passwd[/PHP]
courier-imap
[PHP]cd courier-imap-4.0.3
./configure --prefix=/usr/local --exec-prefix=/usr/local --without-authdaemon --with-authvchkpw --without-authldap --disable-root-check --with-ssl CPPFLAGS=-I/usr/local/include CFLAGS="-DHAVE_OPEN_SMTP_RELAY -DHAVE_VLOGAUTH"
make
make install-strip
cp courier-imap.sysvinit /usr/local/etc/rc.d/courier-imap.sh
chmod 755 /usr/local/etc/rc.d/courier-imap.sh
mkdir -p /var/lock/subsys
cd /usr/local/etc
cp imapd.dist imapd
cp imapd-ssl.dist imapd-ssl
ee imapd.cnf
CN=domail.com
emailAddress=postmaster@domail.com
/usr/local/sbin/mkimapdcert
ee imapd
IMAPDSTART=YES
ee imapd-ssl
IMAPDSSLSTART=YES
/usr/local/etc/rc.d/courier-imap.sh start[/PHP]
SpamAssassin
[PHP]cd /usr/ports/devel/p5-Time-HiRes
make install clean
cd /usr/ports/dns/p5-Net-DNS
make install clean
cd /usr/ports/textproc/p5-PodParser
make install clean
cd /usr/ports/textproc/p5-Parse-Syslog
make install clean
cd /usr/ports/math/p5-Statistics-Distributions
make install clean
tar xzf Mail-SpamAssassin-3.0.4.tar.gz
cd Mail-SpamAssassin-3.0.4
perl Makefile.PL
make
make install
cd /etc/mail/spamassassin
env LANG=C ee local.cf
required_score 6.0
rewrite_header Subject ****这是一封垃圾邮件****
report_safe 1
use_bayes 1
skip_rbl_checks 0
ok_languages zh en ko
ok_locales en ko zh
score HEAD_ILLEGAL_CHARS 0
score SUBJ_ILLEGAL_CHARS 0
score DATE_IN_PAST_03_06 0
score UPPERCASE_25_50 0
score UPPERCASE_50_75 0
score UPPERCASE_75_100 0
score X_MSMAIL_PRIORITY_HIGH 0
score X_PRIORITY_HIGH 0
score TO_TXT 100
score RATWARE_HASH_2 100
score RATWARE_HASH_2_V2 100
score BAYES_99 0.1
score BAYES_80 0.1
score BAYES_60 0.1
score FROM_ILLEGAL_CHARS 0.1
score MIME_BASE64_TEXT 0.1
score NO_RDNS_DOTCOM_HELO 0.1
score CHINA_HEADER 0.1
score NO_REAL_NAME 0.2
score HTML_MESSAGE 0.2
score MIME_HTML_ONLY 0.2
score MIME_HTML_ONLY_MULTI 0.2
score FORGED_MUA_OUTLOOK 0.2
score FORGED_HOTMAIL_RCVD 0.2
score FORGED_OUTLOOK_TAGS 0.2
score MAILTO_TO_SPAM_ADDR 0.2[/PHP]
下载新的垃圾邮件地址列表文件
[PHP]cd /usr/local/share/spamassassin
fetch http://anti-spam.org.cn/rules/sa/55_diy_score.cf[/PHP]
建立SpamAssassin的学习系统
[PHP]/usr/local/bin/sa-learn --rebuild -D -p user_prefs[/PHP]
查看自学习的数据信息
[PHP]/usr/local/bin/sa-learn --dump all[/PHP]
qmail与SpamAssassin结合
[PHP]cd Mail-SpamAssassin-3.0.4/spamc
cc -O -o qmail-spamc qmail-spamc.c
install -m 755 qmail-spamc /var/qmail/bin
ln -s /var/qmail/bin/qmail-queue /usr/bin/qmail-queue[/PHP]
启动spamd
[PHP]/usr/local/bin/spamd --daemonize --pidfile /var/run/spamd.pid[/PHP]
[PHP]ee /etc/rc.local
/usr/local/bin/spamd --daemonize --pidfile /var/run/spamd.pid[/PHP]
qmail-scanner
[PHP]pw groupadd qscand -g 90
pw useradd qscand -c "Qmail-Scanner Account" -u 90 -g 90 -s /bin/false
tar zxvf qmail-scanner-1.25.tgz
cd qmail-scanner-1.25
./configure --admin webmaster --domain domail.com --notify sender,admin --local-domains domail.com --archive yes --add-dscr-hdrs yes --redundant yes --debug yes --unzip yes --scanners clamscan,fast_spamassassin --install[/PHP]
应该有类似提示
[PHP]perlscanner: generate new DB file from /var/spool/qmailscan/quarantine-attachments.txt
perlscanner: total of 9 entries[/PHP]
[PHP]chown -R qscand:qscand /var/spool/qmailscan
ee /etc/tcp.smtp
127.0.0.1.:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
:allow,QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"[/PHP]
[PHP]ee /var/qmail/bin/qmail-scanner-queue.pl
my $V_FROMNAME='管理员';
my $clamscan_options="-r -m --mbox --unzip --unrar --unzoo --lha --disable-summary --max-recursion=10 --max-space=1000000";
my $spamc_subject='疑为垃圾邮件';
qmailctl cdb
qmailctl stop
qmailctl start
qmailctl stat[/PHP]
设置邮件服务器过滤掉一些病毒附件(注:添加文件格式时要手动输入,空格用TAB键补齐!!!)
[PHP]ee /var/spool/qmailscan/quarantine-attachments.txt
.exe 0 系统不允许接收EXE格式的附件
.vbs 0 系统不允许接收VBS格式的附件
.lnk 0 系统不允许接收LNK格式的附件
.scr 0 系统不允许接收SCR格式的附件
.wsh 0 系统不允许接收WSH格式的附件
.hta 0 系统不允许接收HTA格式的附件
.pif 0 系统不允许接收PIF格式的附件
.cpl 0 系统不允许接收CPL格式的附件
.sql 0 系统不允许接收SQL格式的附件
.php 0 系统不允许接收PHP格式的附件
.asp 0 系统不允许接收ASP格式的附件
.com 0 系统不允许接收COM格式的附件
.bat 0 系统不允许接收BAT格式的附件[/PHP]
编辑完成后,运行
[PHP]/var/qmail/bin/qmail-scanner-queue.pl -g[/PHP] 即时生效。
用qmail封mail from
[PHP]ee /var/qmail/control/badmailfrom
这个控制文件实现拒收邮件功能的,每一个地址要单独一行。而且,不用重起qmail就能生效。例如
rpnai@yahoo.com -----限制一个特定的用户
@sina.com -----限制整个域中的邮件[/PHP]
注:Qmail启动脚本有点问题(启动时会提示[PHP]qmail-**** supervise not running[/PHP] ),但是不影响使用。有心有力的朋友帮忙修改一下,谢谢!因为使用ports牵掣到安装目录等问题,所以部分程序采用手动编译。