Qmail Toaster (Linux版)
原文:Bill's Qmail Toaster
整理:FunBSD
版本:0.8
最后更新:2006年1月6日
准备
* 系统需求
* 软件下载
* apache
* php
* mysql
安装
* daemontools
* ucspi-tcp
* netqmail
* vpopmail
* toaster
* courier-imap
* autorespond
* ezmlm
* qmailadmin
* igenus
* squirrelmail
* spamassassin
* clamav
* simscan
* qmailmrtg7
* 系统需求
删除其他MAIL系统:
rpm -e --nodeps sendmail postfix
确认下列软件已安装:
rpm -qa gcc g++ gcc-g++ gdbm gdbm-devel openssl openssl-devel stunnel krb5-devel bzip2 bzip2-devel gmp-devel
* 软件下载
定义环境变量:
export DOMAIN=domain.com
export PKG_DIR=/home/pkg
mkdir -p $PKG_DIR/src
下载软件:
cd $PKG_DIR/src
wget -r -l1 -np -nd http://www.funbsd.net/down/qmail
生成初始安装包:
cd $PKG_DIR
tar xzf src/netqmail-1.05.tar.gz
cd netqmail-1.05
./collate.sh
* apache
安装:
groupadd -g 8080 apache
useradd -u 8080 -g apache apache
cd $PKG_DIR
tar jxf src/httpd-*
cd httpd-*
./configure --prefix=/usr/local/apache --enable-so --enable-modules=most
make
make install
配置(/usr/local/apache/conf/httpd.conf):
NameVirtualHost *:*
DocumentRoot /usr/local/apache/htdocs
ServerName mail.domain.com
设置环境变量,并启动:
echo 'export PATH=/usr/local/apache/bin:$PATH' /etc/profile
echo "/usr/local/apache/bin/apachectl start" /etc/rc.local
export PATH=/usr/local/apache/bin:$PATH
apachectl start
* php
安装:
cd $PKG_DIR
tar jxf src/php-*
cd php-*
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql
make
make install
cp php.ini-recommended /usr/local/apache/conf/php.ini
配置apache(/usr/local/apache/conf/httpd.conf):
DirectoryIndex index.php index.html index.html.var
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
重启apache:
apachectl restart
* mysql
安装:
groupadd -g 3306 mysql
useradd -u 3306 -g mysql -M -d /nonexistent mysql
cd /usr/local
tar zxf $PKG_DIR/src/mysql-standard-*
mv mysql-standard-* mysqld
cd mysql
chown -R root ./
chown -R mysql data
chgrp -R mysql ./
scripts/mysql_install_db --user=mysql
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
chmod 755 /etc/rc.d/init.d/mysql
chkconfig --add mysql
设置环境变量,并启动:
echo 'export PATH=/usr/local/mysql/bin:$PATH' /etc/profile
service mysql start
更改初始密码:
export PATH=/usr/local/mysql/bin:$PATH
mysqladmin -u root password 'mysqlpwd'
* daemontools
daemontools是一个收集可管理的UNIX服务的工具。
网址:http://cr.yp.to/daemontools.html
mkdir /package
chmod 1755 /package
cd /package
tar zxf $PKG_DIR/src/daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1
package/install
* ucspi-tcp
ucspi-tcp包括tcpserver和tcpclient,是一个建立client-server应用程序的命令行工具。
网址:http://cr.yp.to/ucspi-tcp.html
cd $PKG_DIR
tar zxf src/ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1
make
make setup check
* netqmail
netqmail是qmail加上一些推荐的最基本的补丁。
网址:http://qmail.org/netqmail/
mkdir /var/qmail
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails
# 注:有些RedHat/Fedora版本需要执行以下命令才能安装成功
ln -s /usr/kerberos/include/com_err.h /usr/kerberos/include/krb5.h /usr/kerberos/include/profile.h /usr/include/
cd $PKG_DIR/netqmail-1.05/netqmail-1.05
make
make setup check
echo 3 /var/qmail/control/spfbehavior
echo 20 /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
echo ./Maildir/ /var/qmail/control/defaultdelivery
echo postmaster@$DOMAIN /var/qmail/alias/.qmail-root
echo postmaster@$DOMAIN /var/qmail/alias/.qmail-postmaster
echo postmaster@$DOMAIN /var/qmail/alias/.qmail-mailer-daemon
chmod 644 /var/qmail/alias/.qmail*
./config-fast mail.$DOMAIN
* vpopmail
vpopmail是一个基于qmail的邮件虚拟域软件。
网址:http://vpopmail.sf.net/
设置安装环境:
groupadd -g 89 vchkpw
useradd -u 89 -g vchkpw vpopmail
mkdir /home/vpopmail/etc
cd /home/vpopmail/etc
echo "$DOMAIN" defaultdomain
echo '127.:allow,RELAYCLIENT=""' tcp.smtp
tcprules tcp.smtp.cdb tcp.smtp.tmp
echo "localhost|0|vpopuser|vpoppwd|vpopmail" vpopmail.mysql
chmod 640 vpopmail.mysql
chown -R vpopmail:vchkpw ./
mysql -u root --password="mysqlpwd"
CREATE DATABASE vpopmail;
GRANT select,insert,update,delete,create,drop ON vpopmail.*
TO vpopuser@localhost IDENTIFIED BY 'vpoppwd';
FLUSH PRIVILEGES;
QUIT
EOF
安装:
cd $PKG_DIR
tar zxf src/vpopmail-*
cd vpopmail-*
./configure --enable-domainquotas --enable-auth-module=mysql --enable-libdir=/usr/local/mysql/lib --enable-incdir=/usr/local/mysql/include --enable-mysql-limits --enable-sql-logging --enable-logging=v --enable-valias
make
make install-strip
设置邮箱空间警告:
echo "邮件被拒绝,用户的邮箱已满。" /home/vpopmail/domains/.over-quota.msg
cat /home/vpopmail/domains/.quotawarn.msg
From: 邮箱管理员
Reply-To:
Subject: 邮箱空间警告
您的邮箱空间已经达到90%。如果想继续使用,请删除一些信件。
如需帮助,请联系邮箱管理员。
Email : postmaster@$DOMAIN
EOF
添加虚拟域和用户:
echo 'export PATH=/home/vpopmail/bin:$PATH' /etc/profile
export PATH=/home/vpopmail/bin:$PATH
vadddomain -q 100M $DOMAIN pmpwd
vmoddomlimits -q 100M $DOMAIN
vadduser user userpwd
#!/bin/sh
#A simple vadduser script
cat user.txt | while read NAME USER PASSWORD
do
vadduser -c $NAME $USER $PASSWORD
done
安装选项参考:
vpopmail 5.4.10
Current settings
---------------------------------------
vpopmail directory = /home/vpopmail
uid = 89
gid = 89
roaming users = OFF --disable-roaming-users (default)
password learning = OFF --disable-learn-passwords (default)
md5 passwords = ON --enable-md5-passwords (default)
file locking = ON --enable-file-locking (default)
vdelivermail fsync = OFF --disable-file-sync (default)
make seekable = ON --enable-make-seekable (default)
clear passwd = ON --enable-clear-passwd (default)
user dir hashing = ON --enable-users-big-dir (default)
address extensions = OFF --disable-qmail-ext (default)
ip alias = OFF --disable-ip-alias-domains (default)
domain quotas = ON --enable-domainquotas
auth module = mysql --enable-auth-module=mysql
mysql replication = OFF --disable-mysql-replication (default)
sql logging = ON --enable-sql-logging
mysql limits = ON --enable-mysql-limits
MySQL valias = ON --enable-valias
auth inc = -I/usr/local/mysql/include
auth lib = -L/usr/local/mysql/lib -lmysqlclient -lz -lm
system passwords = OFF --disable-passwd (default)
pop syslog = log success and errors including passwords
--enable-logging=v
auth logging = ON --enable-auth-logging (default)
all domains in one SQL table = --enable-many-domains (default)
* toaster
Bill's Qmail Toaster。
网址:http://shupp.org/
安装:
cd $PKG_DIR
tar zxf src/toaster-scripts-0.8.tar.gz
cd netqmail-1.05/netqmail-1.05
bunzip2 -c ../../src/qmail-toaster-0.8.patch.bz2 | patch -p0
make clean
make
make setup check
make cert
make tmprsadh
chown -R vpopmail:vchkpw /var/qmail/spam
crontab -e
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=postmaster@domain.com
HOME=/root
0 0 * * * /var/qmail/bin/update_tmprsadh /dev/null 2%26amp;1
添加运行脚本:
cd $PKG_DIR
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
mkdir -p /var/qmail/supervise/qmail-pop3ds/log
cp toaster-scripts-0.8/send.run /var/qmail/supervise/qmail-send/run
cp toaster-scripts-0.8/send.log.run /var/qmail/supervise/qmail-send/log/run
cp toaster-scripts-0.8/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp toaster-scripts-0.8/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp toaster-scripts-0.8/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp toaster-scripts-0.8/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run
cp toaster-scripts-0.8/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp toaster-scripts-0.8/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run
mkdir -p /var/log/qmail/smtpd
mkdir -p /var/log/qmail/pop3d
mkdir -p /var/log/qmail/pop3ds
chown -R qmaill /var/log/qmail
cp toaster-scripts-0.8/rc /var/qmail
cp toaster-scripts-0.8/qmailctl /var/qmail/bin
cp toaster-scripts-0.8/vpopmailctl /var/qmail/bin/vpopmailctl
chmod 755 /var/qmail/rc
chmod 755 /var/qmail/bin/qmailctl
chmod 755 /var/qmail/bin/vpopmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s /var/qmail/bin/vpopmailctl /usr/bin
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
启动:
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
ln -s /var/qmail/supervise/qmail-pop3d /var/qmail/supervise/qmail-pop3ds /service
相关命令:
qmailctl {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}
vpopmailctl {start|stop|restart|stat|pause|cont|help}
到这里qmail安装完成,可用outlook或foxmail进行测试。
* courier-imap
Courier-IMAP支持通过IMAP/SIMAP访问邮件系统。
网址:http://www.courier-mta.org/
安装Courier认证库:
cd $PKG_DIR
tar jxf src/courier-authlib-0.58.tar.bz2
cd courier-authlib-0.58
./configure --with-redhat
# 注: RedHat/Fedora需要加"--with-redhat"选项
make
make install-strip
make install-configure
cp courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib
chkconfig --add courier-authlib
安装Courier-IMAP:
cd $PKG_DIR
tar jxf src/courier-imap-4.0.6.tar.bz2
cd courier-imap-4.0.6
chown -R vpopmail:vchkpw ./
su vpopmail
./configure --with-redhat
# 注: RedHat/Fedora需要加"--with-redhat"选项
make
exit
make install-strip
make install-configure
cp courier-imap.sysvinit /etc/init.d/courier-imap
chmod 755 /etc/init.d/courier-imap
chkconfig --add courier-imap
设置:
cd /usr/local/etc/authlib
sed -i".bak" 's/^authmodulelist=.*/authmodulelist="authvchkpw"/g' authdaemonrc
cd /usr/lib/courier-imap/etc
sed -i".bak" "s/^IMAPDSTART=.*/IMAPDSTART=YES/g;s/^MAXPERIP=.*/MAXPERIP=500/g" imapd
sed -i".bak" "s/^IMAPDSSLSTART=.*/IMAPDSSLSTART=YES/g" imapd-ssl
sed -i".bak" "s/^CN=.*/CN=mail.$DOMAIN/g;s/^emailAddress=.*/emailAddress=postmaster@$DOMAIN/g" imapd.cnf
启动:
service courier-authlib start
service courier-imap start
* autorespond
autorespond是一个自动回复工具。
网址:http://qmailadmin.sf.net
安装:
cd $PKG_DIR
tar zxf src/autorespond-2.0.4.tar.gz
cd autorespond-2.0.4
patch -p1
make
make install
* ezmlm
ezmlm是一个快速,强大的邮件列表程序。
网址:http://www.ezmlm.org/
安装:
cd $PKG_DIR
tar zxf src/ezmlm-0.53.tar.gz
tar zxf src/ezmlm-idx-0.443.tar.gz
mv -f ezmlm-idx-0.443/* ezmlm-0.53/
cd ezmlm-0.53
patch -p0
make
make man
make ch_GB
make setup
* qmailadmin
qmailadmin除了不能添加删除虚拟域外,几乎可以完成所有其他的虚拟域管理。
网址:http://qmailadmin.sf.net
安装:
cd $PKG_DIR
tar zxf src/qmailadmin-1.2.9.tar.gz
tar zxf src/qmailadmin-help-1.0.8.tar.gz
cd qmailadmin-1.2.9
./configure --enable-htmldir=/usr/local/apache/htdocs --enable-cgibindir=/usr/local/apache/cgi-bin --enable-maxusersperpage=20 --enable-maxaliasesperpage=20 --enable-domain-autofill --enable-modify-quota --enable-help --disable-ezmlm-mysql
make
make install-strip
cd /usr/local/share/qmailadmin/lang
mv en en.bak
cp zh-cn en
cd $PKG_DIR
cp -r qmailadmin-help-1.0.8 /usr/local/apache/htdocs/images/qmailadmin/help
测试:
http://mail.domain.com/cgi-bin/qmailadmin
安装选项参考:
qmailadmin 1.2.9
Current settings
---------------------------------------
cgi-bin dir = /usr/local/apache/cgi-bin
html dir = /usr/local/apache/htdocs
image dir = /usr/local/apache/htdocs/images/qmailadmin
image URL = /images/qmailadmin
template dir = /usr/local/share/qmailadmin
qmail dir = /var/qmail
vpopmail dir = /home/vpopmail
autorespond dir = /usr/local/bin
ezmlm dir = /usr/local/bin/ezmlm
ezmlm idx = yes
mysql for ezmlm = no
help = yes
modify quota = yes
domain autofill = yes
modify spam check = no
* igenus
这是国内一个开源的webmail。
网址:http://www.igenus.org
安装:
cd /usr/local/apache/htdocs
tar zxf $PKG_DIR/src/igenus*
配置(/usr/local/apache/htdocs/igenus/config/config_inc.php):
// 安装位置
$CFG_BASEPATH = "/usr/local/apache/htdocs/igenus";
// 数据库账号
$CFG_MYSQL_HOST = 'localhost';
$CFG_MYSQL_USER = 'vpopuser';
$CFG_MYSQL_PASS = 'vpoppwd';
$CFG_MYSQL_DB = 'vpopmail';
// 临时目录
$CFG_TEMP = $CFG_BASEPATH."/temp";
// autorespond的位置
$CFG_AUTORESPOND_PROM = "/usr/bin/autorespond";
// 网络目录
$CFG_NETDISK_PATH = $CFG_BASEPATH."/netdisk";
创建相关目录:
cd /usr/local/apache/htdocs/igenus
mkdir temp netdisk
chown -R vpopmail:vchkpw ./
修改并导入表:
mysql -uroot --password="mysqlpwd"
alter table vpopmail.vpopmail drop primary key;
alter table vpopmail.vpopmail add column pw_id int(5) unsigned NOT NULL PRIMARY KEY auto_increment;
alter table vpopmail.vpopmail add KEY pw_name (pw_name,pw_domain);
QUIT
EOF
mysql -uroot --password="mysqlpwd" -f vpopmail
修改apache配置文件(/usr/local/apache/conf/httpd.conf):
User vpopmail
Group vchkpw
修改php配置文件(/usr/local/apache/conf/php.ini):
register_globals = On
session.auto_start = 1
session.bug_compat_warn = 0
max_execution_time = 60
memory_limit = 20M
upload_max_filesize = 10M
post_max_size = 10M
log_errors = Off
Sendmail = /var/qmail/bin/qmail-inject
重启apache:
apachectl restart
测试:
http://mail.domain.com/igenus
* squirrelmail
squirrelmail是一个基于imap的webmail。
网址:http://www.squirrelmail.org
安装:
cd $PKG_DIR
tar jxf src/squirrelmail-*
tar zxf src/quota_usage-*
cd squirrelmail-*
tar zxf ../src/all_locales-*
cp ../quota_usage/config.php.sample ../quota_usage/config.php
mv ../quota_usage plugins
./configure
1. 1. Domain
1. 4. Domain WebMail $version
1. 7. http://www.Domain.com/
1. 8. Domain Corp.,Ltd
2. 1. domain.com
2. A. 8. courier
2. B. 7. login
3. 3. INBOX.垃圾箱
3. 4. INBOX.发件箱
3. 5. INBOX.草稿箱
8. 11
10. 1. zh_CN
10. 2. gb2312
s
q
cd ../
mv squirrelmail-* /usr/local/apache/htdocs/squirrel
chown -R vpopmail:vchkpw /usr/local/apache/htdocs/squirrel
修改apache配置文件(/usr/local/apache/conf/httpd.conf):
User vpopmail
Group vchkpw
重启apache:
apachectl restart
测试:
http://mail.domain.com/squirrel
* spamassassin
squirrel是一个垃圾邮件过滤程序。
网址:http://spamassassin.apache.org/
安装:
cd /root
perl -MCPAN -e shell
o conf prerequisites_policy ask
install Digest::SHA1
install DB_File
install Net::DNS
install Mail::SPF::Query
install IP::Country
install Razor2
install Net::Ident
install IO::Socket::INET6
install IO::Socket::SSL
install Time::HiRes
install DBI
install Archive::Tar
install IO::Zlib
install Mail::SpamAssassin
cd $PKG_DIR
cp toaster-scripts-0.8/local.cf /etc/mail/spamassassin/local.cf
mkdir /etc/mail/spamassassin/.spamassassin
chown vpopmail /etc/mail/spamassassin/.spamassassin
mkdir -p /var/qmail/supervise/spamd/log /var/log/spamd
chown qmaill /var/log/spamd
cp toaster-scripts-0.8/spamd.run /var/qmail/supervise/spamd/run
cp toaster-scripts-0.8/spamd.log.run /var/qmail/supervise/spamd/log/run
chmod 755 /var/qmail/supervise/spamd/run
chmod 755 /var/qmail/supervise/spamd/log/run
ln -s /var/qmail/supervise/spamd /service
* clamav
clamav是一个开源的防毒软件。
网址:http://www.clamav.net/
安装:
groupadd clamav
useradd clamav -g clamav -M -d /nonexistent
cd $PKG_DIR
tar zxf src/clamav-0.87.1.tar.gz
cd clamav-0.87.1
patch -p0
patch -p0
patch -p0
./configure
make
make install
在daemontools下运行clamd:
cd $PKG_DIR
mkdir -p /var/qmail/supervise/clamd/log /var/log/clamd
chown clamav /var/log/clamd
cp toaster-scripts-0.8/clamd.run /var/qmail/supervise/clamd/run
cp toaster-scripts-0.8/clamd.log.run /var/qmail/supervise/clamd/log/run
chmod 755 /var/qmail/supervise/clamd/run
chmod 755 /var/qmail/supervise/clamd/log/run
ln -s /var/qmail/supervise/clamd /service
病毒库升级程序:
cd $PKG_DIR
touch /var/log/freshclam.log
chmod 600 /var/log/freshclam.log
chown clamav /var/log/freshclam.log
cp toaster-scripts-0.8/freshclam /etc/init.d/freshclam
chmod 755 /etc/init.d/freshclam
ln -s ../init.d/freshclam /etc/rc0.d/K30freshclam
ln -s ../init.d/freshclam /etc/rc1.d/K30freshclam
ln -s ../init.d/freshclam /etc/rc2.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc3.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc4.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc5.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc6.d/K30freshclam
/etc/init.d/freshclam start
* simscan
simscan是qmail的垃圾邮件和病毒扫描引擎。
网址:http://www.inter7.com/simscan/
安装ripmime:
cd $PKG_DIR
tar zxf src/ripmime-1.4.0.5.tar.gz
cd ripmime-1.4.0.5
make
make install
安装simscan:
cd $PKG_DIR
tar zxf src/simscan-1.1.tar.gz
cd simscan-1.1
./configure --enable-user=clamav --enable-clamav=y --enable-spam=y --enable-spam-passthru=y --enable-per-domain=y --enable-ripmime --enable-attach=y --enable-received=y
make
make install-strip
echo ":clam=yes,spam=yes,spam_passthru=yes,attach=.vbs:.lnk:.scr:.wsh:.hta:.pif" /var/qmail/control/simcontrol
/var/qmail/bin/simscanmk
/var/qmail/bin/simscanmk -g
echo ':allow,QMAILQUEUE="/var/qmail/bin/simscan"' ~vpopmail/etc/tcp.smtp
qmailctl cdb; qmailctl restart
* qmailmrtg7
qmailmrtg7是一个监测qmail流量的工具。
网址:http://www.inter7.com/qmailmrtg7/
安装mrtg:
cd $PKG_DIR
tar zxf src/mrtg-*
cd mrtg-*
./configure --prefix=/usr/local
make
make install
安装qmailmrtg7:
cd $PKG_DIR
tar zxf src/qmailmrtg7-4.2.tar.gz
cd qmailmrtg7-4.2
patch -p0
make
make install
sed -i "s/FQDN/mail.$DOMAIN/g;" qmail.mrtg.cfg
sed -i "1s/.*/WorkDir: \/usr\/local\/apache\/htdocs\/qmailmrtg/" qmail.mrtg.cfg
cp qmail.mrtg.cfg /etc
mkdir /usr/local/apache/htdocs/qmailmrtg
indexmaker --section=title /etc/qmail.mrtg.cfg /usr/local/apache/htdocs/qmailmrtg/index.html
mrtg /etc/qmail.mrtg.cfg; mrtg /etc/qmail.mrtg.cfg; mrtg /etc/qmail.mrtg.cfg
crontab -e
*/5 * * * * /usr/local/bin/mrtg /etc/qmail.mrtg.cfg /dev/null
测试:
http://mail.domain.com/qmailmrtg