Postfix免费邮件系统方案
1、系统目标
Maildir邮件存储格式
smtp认证
邮件地址和系统帐号分开
多域支持
web管理帐号、别名、域等资料
pop3/imap支持
webmail支持
集成mysql数据库
2、TODO
集成垃圾邮件过滤
集成防病毒
Project:xx公司邮件系统解决方案
Date:
Author:
1、系统目标
Maildir邮件存储格式
smtp认证
邮件地址和系统帐号分开
多域支持
web管理帐号、别名、域等资料
pop3/imap支持
webmail支持
集成mysql数据库
2、TODO
集成垃圾邮件过滤
集成防病毒
3、系统架构
+---------------------------------------------------+
| |
| 25/25 25/25 110/993 143/995 80/443 |
| Incoming Outgoing POP3 IMAP WEB-MAIL |
| / / / / / |
| || || || || || |
| / / / / / |
+-------------------+---------------+---------------+
| Postfix | | Squirrelmail |
| | +---------------+
| | Courier-imap |
| +-----------+-------------------------------+
| + Courier-authlib +
| |-------------------------------------------|
| | Cyrus-SASL |
|-------+-------------------------------------------+
| MySQL |
+---------------------------------------------------+
4、系统安装
操作系统采用debian 3.1(sarge),下面没有独立安装的gcc,make,db,glibc等基本库和软件,邮件系统需要的全部用 apt-get install 包名称 来安装
mail~#apt-get install gcc make
mail~#apt-get install libdb4-*
mail~#apt-get install curses*
mail~#apt-get install termcap*
..............
4.1、mysql
mail~#wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.12.tar.gz/from/http://mysql.cbn.net.id/
mail~#groupadd mysql
mail~#useradd -g mysql mysql
mail~#tar zxvf /usr/src/mail/mysql-4.1.12.tar.gz -C /tmp
mail~#cd /tmp/mysql-4.1.12
mail~#./configure --prefix=/opt/mysql --localstatedir=/opt/mysql/data --with-unix-socket-path=/tmp/mysql.sock --with-mysql-user=mysql --with-charset=gb2312 --with-extra-charsets=all
mail~#make
mail~#make install
mail~#chown -R mysql:mysql /opt/mysql/data/
如果没有/opt/mysql/var/mail.err,就手动创建一个
mail~#mkdir /opt/mysql/var
mail~#touch /opt/mysql/var/mail.err
mail~#/opt/mysql/bin/mysqld_safe --user=mysql & #起动mysql服务
mail~#/opt/mysql/bin/mysql #起动mysql客户端
mail~#vi /etc/ld.so.conf,添加
/opt/mysql/lib/mysql
mail~#ldconfig
mail~#cp /opt/mysql/share/mysql/mysql.server /etc/init.d/mysqld
mail~#chmod 755 /etc/init.d/mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc3.d/S52mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc5.d/S52mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc0.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc1.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc2.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc4.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc6.d/K25mysqld
4.2、apahce
mail~#wget http://apache.justdn.org/httpd/apache_1.3.33.tar.gz
mail~#goupadd www
mail~#useradd -g www -d /dev/null -s /bin/false www
mail~#tar zxvf /usr/src/mail/apache_1.3.33.tar.gz -C /tmp
mail~#cd /tmp/apache_1.3.33
mail~#./configure --prefix=/opt/apache --enable-module=rewrite --enable-shared=rewrite --enable-module=proxy --enable-shared=proxy --enable-module=so --server-uid=www --server-gid=www
mail~#make
mail~#make install
mail~#/opt/mysql/var# /opt/apache/bin/apachectl start #起动apache服务器
mail~#cd /opt/apache/bin/
mail~#cp apachectl /etc/init.d/httpd
mail~#cd /etc/init.d/
mail~#chmod 755 httpd
mail~#ln -s /etc/init.d/httpd /etc/rc3.d/S51httpd
mail~#ln -s /etc/init.d/httpd /etc/rc5.d/S51httpd
mail~#ln -s /etc/init.d/httpd /etc/rc0.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc1.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc2.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc4.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc6.d/K15httpd
4.3、php4
mail~#wget http://cn2.php.net/get/php-4.3.11.tar.gz/from/cn.php.net/mirror
mail~#tar zxvf /usr/src/mail/php-4.3.11.tar.gz -C /tmp
mail~#cd /tmp/php-4.3.11
mail~#./configure --prefix=/opt/php4 --with-xml --with-mysql=/opt/mysql --with-mysql-sock=/tmp/mysqld.php4.sock --with-apxs=/opt/apache/bin/apxs
mail~#make
mail~#make install
mail~#cp php.ini-dist /opt/php4/lib/php.ini
修改/opt/apache/conf/httpd.conf,添加php4支持,添加内容如下:
#php 4
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
另更改
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>
为
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
mail~#vi /opt/apache/htdocs/test.php,内容如下
<?php
phpinfo();
?>
mail~#/opt/mysql/var# /opt/apache/bin/apachectl restart #重启apache服务器
使用lynx或常用的浏览器如IE、firefox,浏览http://ip/test.php,看到了PHP的信息页面,OK
4.4、openssl
mail~#wget http://www.openssl.org/source/openssl-0.9.8.tar.gz
mail~#tar zxvf /usr/src/mail/openssl-0.9.8.tar.gz -C /tmp
mail~#cd /tmp/openssl-0.9.8
mail~#./configure --prefix=/opt/openssl
mail~#make
mail~#make install
mail~#ln -s /opt/openssl/include/openssl /usr/include/openssl
4.5、cyrus-sasl2
mail~#wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz
mail~#tar zxvf /usr/src/mail/cyrus-sasl-2.1.21.tar.gz -C /tmp
mail~#cd /tmp/cyrus-sasl-2.1.21
mail~#./configure --prefix=/opt/sasl2 --enable-login --enable-plain --enable-sql --enable-pwcheck --disable-anon --disable-digest --with-mysql=/opt/mysql --with-mysql-includes=/opt/mysql/include/mysql --with-mysql-libs=/opt/mysql/lib/mysql --with-saslauthd=/var/run
mail~#make
如果出现下面的错误:
auth_getpwent.c:48:20: des.h: No such file or directory
make[3]: *** [auth_getpwent.o] Error 1
make[3]: Leaving directory `/tmp/cyrus-sasl-2.1.21/saslauthd'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/cyrus-sasl-2.1.21/saslauthd'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/cyrus-sasl-2.1.21'
make: *** [all] Error 2
修改/tmp/cyrus-sasl-2.1.21/saslauthd/Makefiles内的变量CFLAGS添加-I/opt/openssl/include/openssl
或者直接
mail~#cp /tmp/cyrus-sasl-2.1.21/mac/libdes/public/des.h /tmp/cyrus-sasl-2.1.21/
mail~#make
mail~#make install
mail~#vi /etc/ld.so.conf #添加以下内容
/usr/lib/sals2
/opt/sasl2/lib/sasl2
mail~#ldconfig
4.6、postfix
mail~#wget http://postfix.it-austria.net/releases/official/postfix-2.2.4.tar.gz
mail~#groupadd postfix
mail~#ueradd -g postfix -d /dev/null -s /bin/false postfix
mail~#make makefiles 'CCARGS=-DHAS_MYSQL -I/opt/mysql/include/mysql -DUSE_SASL_AUTH -I/opt/sasl2/include/sasl' 'AUXLIBS=-L/opt/mysql/lib/mysql -lmysqlclient -lm -lz -L/opt/sasl2/lib/sasl2 -lsasl2'
mail~#make install #一路回车默认就可以了
mail~#vi /etc/init.d/postfix
#!/bin/sh
start() {
#Start daemons.
echo -n "Starting postfix: "
/usr/sbin/postfix start
}
stop() {
#Stop daemons.
echo -n "Shutting down postfix: "
/usr/sbin/postfix stop
}
reload(){
echo -n "Reloading postfix: "
/usr/sbin/postfix reload
}
restart(){
stop
start
}
abort(){
/usr/sbin/postfix abort
}
flush(){
/usr/sbin/postfix flush
}
check(){
/usr/sbin/postfix check
}
case $1 in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
*)
echo "Usage: postfix {start|stop|restart|reload|abort|flush|check}"
esac
mail~#chmod 755 /etc/init.d/postfix
mail~#ln -s /etc/init.d/postfix /etc/rc3.d/S53postfix
mail~#ln -s /etc/init.d/postfix /etc/rc5.d/S53postfix
mail~#ln -s /etc/init.d/postfix /etc/rc0.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc1.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc2.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc4.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc6.d/K35postfix
4.7、courier-authlib
mail~#wget http://www.courier-mta.org/beta/courier-authlib/courier-authlib-0.56.20050709.tar.bz2
mail~#su - wxt
wxt@mail:~$ tar xjvf /usr/src/mail/courier-authlib-0.56.20050709.tar.bz2 -C /tmp
wxt@mail:~$cd /tmp/courier-authlib-0.56.20050709/
wxt@mail:~$./configure --with-authmysql=yes --with-mailuser=www --with-mailgroup=www
--with-mysql-libs=/opt/mysql/lib/mysql --with-mysql-includes=/opt/mysql/include
/mysql --prefix=/opt/courier-authlib
wxt@mail:~$make
wxt@mail:~$exit
mail~#make install
4.8、courier-imap
mail~#wget http://www.courier-mta.org/beta/imap/courier-imap-4.0.3.20050702.tar.bz2
mail~#tar zxvf courier-imap-4.0.3.20050702.tar.bz2
mail~#su - wxt
wxt@mail:~$./configure --enable-unicode=utf-8,iso-8859-1,gb2312,gbk,gb18030,big5 --prefix=/opt/courier-imap --disable-root-check --with-trashquota --with-dirsync
哪果没能完成,出错提示如下
configure: WARNING: === Courier authentication library not found.
configure: WARNING: === You need to download and install
configure: WARNING: === http://www.courier-mta.org/download.php#authlib first.
configure: WARNING: === If courier-authlib is installed in a non-default
configure: WARNING: === directory, set the COURIERAUTHCONFIG environment
configure: WARNING: === variable to the full path to the courierauthconfig
configure: WARNING: === binary and rerun this configure script.
configure: WARNING:
configure: error: courierauthconfig not found
设置变量COURIERAUTHCONFIG
【返回】