3. 注册Postfix为系统服务
        #chmod +x /etc/init.d/postfix
        #chkconfig --add  postfix
#chkconfig --level 35  postfix on
#service postfix start

五、安装配置courier-imap (用于实现pop3,imap收邮件功能)

1、安装courier-imap

        #tar -jxvf courier-imap-4.5.1.tar.bz2
        #cd courier-imap-4.5.1
        #./configure --prefix=/usr/local/courier-imap --enable-unicode --disable-root-check --with-trashquota --without-ipv6 
CPPFLAGS='-I/usr/local/courier-authlib/include' LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib'
COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig'
#make
#make install
 
复制配置文件
#cd /usr/local/courier-imap/
#cp ./etc/imapd.dist ./etc/imapd
#cp ./etc/imapd-ssl.dist ./etc/imapd-ssl
#cp ./etc/pop3d.dist ./etc/pop3d
#cp ./etc/pop3d-ssl.dist ./etc/pop3d-ssl
 
配置Courier-IMAP,为用户提供pop3服务
#vi ./etc/pop3d
POP3DSTART=YES
注意:如果你想为用户提供IMAP服务,则需在"/usr/local/courier-imap/etc/imapd"文件中设置"IMAPDSTART=yes";其它类同;
 
设置开机启动
#cd /root/tools/postfix/courier-imap-4.5.1/
#cp courier-imap.sysvinit  /etc/init.d/courier-imapd
#chmod 755 /etc/init.d/courier-imapd
#chkconfig --add courier-imapd
#chkconfig --level 35 courier-imapd on
#service courier-imapd start
 
新建虚拟用户邮箱所在的目录
新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
#mkdir –pv /var/mailbox
#chown -R postfix /var/mailbox
 
重新配置SMTP 认证
#vi /usr/local/sasl2/lib/sasl2/smtpd.conf
确保其为以下内容:
pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN
LOGIN  authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
 
重新启动sasal服务
#killall -9 saslauthd
#/usr/local/sasl2/sbin/saslauthd -a shadow pam
 

六、安装配置webmail系统(extmail+extman

(extmail 用于实现web mail)
(extman 用于邮件服务器的后台管理)

1、安装extmail

#tar -zxvf extmail-1.0.9.tar.gz
#cp -rf extmail-1.0.9  /usr/local/apache/htdocs/extmail
#cd /usr/local/apache/htdocs/extmail
#cp webmail.cf.default  webmail.cf
 

2、配置extmail

#vi webmail.cf
部分修改选项的说明:
SYS_CONFIG = /usr/local/apache/htdocs/extmail/
SYS_LANGDIR = /usr/local/apache/htdocs/extmail/lang
SYS_TEMPLDIR = /usr/local/apache/htdocs/extmail/html
SYS_MESSAGE_SIZE_LIMIT = 5242880    //用户可以发送的最大邮件
SYS_USER_LANG = en_US               //语言选项,
可改作: SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /home/domains    //此处即为您在前文所设置的用户邮件的存放目录
可改作: SYS_MAILDIR_BASE = /var/mailbox
SYS_MYSQL_USER = db_user
SYS_MYSQL_PASS = db_pass
以上两句句用来设置连接数据库服务器所使用用户名、密码和邮件服务器用到的数据库,这里修改为:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_HOST = localhost  //指明数据库服务器主机名,这里默认即可 SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock   //连接数据库的sock文件位置
这里修改为: SYS_MYSQL_SOCKET = /tmp/mysql.sock
SYS_MYSQL_TABLE = mailbox
SYS_MYSQL_ATTR_USERNAME = username
 SYS_MYSQL_ATTR_DOMAIN = domain
SYS_MYSQL_ATTR_PASSWD = password   //以上用来指定验正用户登录里所用到的表,以及用户名、域名和用户密码分别对应的表中列的名称这里默认即可
SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket //此句用来指明authdaemo socket文件的位置这里修改为SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
 

3.  安装Extman

#tar -zxvf extman-1.0.0.tar.gz
#cp -r extman-1.0.0  /usr/local/apache/htdocs/extman
#cd /usr/local/apache/htdocs/extman
#mkdir /var/tmp/extman
#chown postfix.postfix /var/tmp/extman
#chown -R postfix.postfix cgi
 

4、配置Extman

#vi webman.cf
修改如下配置
SYS_CONFIG = /usr/local/apache/htdocs/extman/
SYS_LANGDIR = /usr/local/apache/htdocs/extman/lang
SYS_TEMPLDIR = /usr/local/apache/htdocs/extman/html
SYS_MAILDIR_BASE = /home/domains //此处即为您在前文所设置的用户邮件的存放目录
可改作: SYS_MAILDIR_BASE = /var/mailbox/
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
 此处修改为: SYS_MYSQL_SOCKET = /tmp/mysql.sock
 SYS_SESS_DIR = /var/tmp/extman/
SYS_CAPTCHA_ON = 0 (关闭显示校验码或者安装perl-GD模块
 

5、建立数据库

使用extman源码目录下docs目录中的extmail.sqlinit.sql建立数据库:
#cd docs/
#mysql -u root -p <extmail.sql
#mysql -u root -p <init.sql
mysql>grant all privileges on extmai.* TO extmail@localhost IDENTIFIED BY 'extmail';

6、修改Apache编写虚拟主机

#vi /usr/local/apache/conf/httpd.conf
Include conf/extra/httpd-vhosts.conf   //去掉之前注释
 
#cd /usr/local/apache/conf/extra/
#vi httpd-vhosts.conf(内容修改如下)
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/extmail/html/"
    ServerName  mail.lixin.org
    ScriptAlias /extmail/cgi/  /usr/local/apache/htdocs/extmail/cgi/
    Alias /extmail/  /usr/local/apache/htdocs/extmail/html/
    ScriptAlias /extman/cgi/  /usr/local/apache/htdocs/extman/cgi/
    Alias /extman/  /usr/local/apache/htdocs/extman/html/
    <Directory "/usr/local/apache/htdocs/">
         Options FollowSymLinks
         Allowoverride none
         Order allow,deny
         Allow from all
    </Directory>
</VirtualHost>
 
#service httpd stop
#service httpd start
 
安装Unix-Syslog前提系统已经安装了perl
#tar zxvf Unix-Syslog-0.100.tar.gz
#cd Unix-Syslog-0.100
#perl Makefile.PL
#make
#make install
 
安装DBD-Mysql
#tar zxvf DBD-mysql-4.012.tar.gz
#cd DBD-mysql-4.012
#perl Makefile.PL  --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -L/usr/lib -lz " --cflags=-I/usr/local/mysql/include/mysql  --mysql_config=/usr/local/mysql/bin/mysql_config
#make
#make install
 
在浏览器中输入以下连接进行访问:mail.lixin.org
进入邮件服务器,添加域与添加用户邮箱。默认管理帐号为:root@extmail.org 密码为:extmail*123*.