Mysql+apache+php+cyrus-sasl+postfix+postfixadmin+courier-authlib+courier+maildrop+webmail

所用软件包
1.mysql-5.0.18.tar.gz; 提供数据库支持
2.httpd-2.2.8.tar.gz; WEB服务器
3.php-5.2.5.tar.gz; 一种解释型语句
4.postfixadmin-2.1.0.tgz; 一组从浏览器管理Postfix的PHP
5.cyrus-sasl-2.1.22.tar.gz; 为SMTP服务器提供验证
6.postfix-2.6.tar.gz; 邮件传输代理(MTA)和SMTP服务器
7.courier-authlib-0.59.3.tar.tar 为IMAP和POP3服务器提供验证
8.courier-imap-4.1.3.tar.bz2 IMAP服务器和POP3服务器
9.maildrop-2.0.1.tar.bz2
先安装pcre-6.3.tar.bz2
10.squirrelmail-1.4.13.tar.gz; 基于IMAP协议的webmail电子邮件客户端
中文包zh_CN-1.4.5-20050904.tar.bz2
还有三个插件
quota_usage-1.3-1.2.7.tar.gz 用来显示邮箱的使用情况的
compatibility-2.0.2.tar.gz 用来修改密码的
change_mysqlpass-3.2-1.2.8.tar.gz

Q代表安装过程中遇到的问题。A:代表解决方法

一.安装mysql
# tar zxvf mysql-5.0.18.tar.gz
# cd cd mysql-5.0.18
# groupadd mysql
# useradd -g mysql mysql
#./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charsets=utf8,gb2312,big5 --enable-thread-safe-client
# make
# make install
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysql
#chkconfig --add mysqld
#chkconfig --level 123456 mysqld on
安装完以后要初始化数据库
# cd /usr/local/mysql
# /usr/local/mysql/bin/mysql_install_db --user=mysql
# /usr/local/mysql/bin/mysqld_safe --user=root&
# chown -R mysql var
# chgrp -R mysql .
启动mysql
#/etc/init.d/mysql start 或#/usr/local/mysql/share/mysql/mysql.server start
#ss -ant | grep 3306

为了能让系统找到mysql,请运行如下命令
# PATH=$PATH:/usr/local/mysql/bin
# export PATH
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig
Q:编译php的时候会提示一个mysql的错误(忘了什么提示了)
A: mysql版本4最好加 --enable-thread-safe-client,如果你用mysql 5的话可不加 (具体原因不知道.查资料才知道的)

二、安装apache
卸载原rpm包
#rpm -qa |grep httpd
#rmp -e --nodeps httpd-x.x.

# groupadd vmail -g 1001
# useradd vmail -u 1001 -g 1001 -s/sbin/nologin -d/dev/null
# tar zxvf httpd-2.2.18.tar
# cd httpd-2.2.18
# ./configure --prefix=/usr/local/apache
# make
# make install

修改/etc/init.d/httpd
# vi /etc/init.d/httpd(前面几行改成如下样子)
#!/bin/sh
#
# Startup script for the Apache Web Server
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache/log/httpd.pid
# config: /usr/local/apache/conf/httpd.conf

设置自启动
# cp support/apachectl /etc/init.d/httpd
# chmod +x /etc/init.d/httpd
# chkconfig --add httpd
# chkconfig --level 2345 httpd on
# /etc/init.d/httpd start

创建网页根目录
# mkdir /var/www

修改apache配置文件
# vi /usr/local/apache/conf/httpd.conf
//存放网页的目录,原来为DocumentRoot "",改成:
DocumentRoot "/var/www"
//这句应该和DocumentRoot 的目录保持一致,原来为<Directory "">,改成:
<Directory "/var/www">
//Indexes:当在目录中找不到DirectoryIndex列表中指定的文件就生成当前目录的文件列表
//FollowSymlinks:允许符号链接跟随,访问不在本目录下的文件
Options Indexes FollowSymLinks
//禁止读取.htaccess配置文件的内容
AllowOverride None
//指定先执行Allow(允许)访问规则,再执行Deny(拒绝)访问规则
Order allow,deny
//设置Allow(允许)访问规则,允许所有连接
Allow from all
</Directory>

三、安装PHP
# tar zxvf php-5.2.5.tar
# cd php-5.2.5
# mkdir /usr/local/php
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
#make
#make install
#cp php.ini-dist /usr/local/php/lib/php/php.ini

# vi /usr/local/apache/conf/httpd.conf
找到#AddType application/x-tar .tgz 这行,在下面加两行
AddType application/x-httpd-php .php
AddType applichtion/x-httpd-source .phps
找到下面一行在后面加上index.php,这表示网站的默认页也能够为index.php
DirectoryIndex index.html index.html.var index.php

把User nobody
Group #-1
改为
User vmail
Group vmail
重启APACHE

Q:重新起动APACHE出现:/usr/local/apache/bin/apachectl start Syntax error on line 232 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

A: 那就要按照下面的方法解决:(selinux 阻止加载libphp5.so)将此关闭
#vi /etc/senlinux/config
将"SELINUX=enforcing" 注释掉 在其下面添加这行
SELINUX=disabled
#vi /etc/sysconfig/selinux
将"SELINUX=enforcing" 注释掉 在其下面添加这行
SELINUX=disabled
重启系统再重启httpd OK !

四、安装postfixadmin

#tar -zxvf postfixadmin-2.1.0.tar
#cp -R postfixadmin-2.1.0 /var/www/postfixadmin
#chown -R vmail:vmail /var/www/postfixadmin
导入postfixadmin的数据库
#/usr/local/mysql/bin/mysql -u root -p < /www/var/postfixadmin/DATABASE_MYSQL.TXT
# cp config.inc.php.sample config.inc.php
# vi config.inc.php
本例中的配置如下: 跟参考帖一样没动
$CONF['default_language'] = 'test.com';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixadmin';
$CONF['database_password'] = 'postfixadmin';
$CONF['database_name'] = 'postfix';
$CONF['encrypt'] = 'md5crypt';
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['quota'] = 'YES';
$CONF['quota_multiplier'] = '1024000';
然后打开浏览器,输入http://yourdomin/postfixadmin 进入postfixadmin的欢迎界面,点击网页上的setup,看看检查是否通过,然后删除setup.php和.*txt文件。
Q: 如果出现问题想重新导入.mysql 会提示导入错误
A: 近入数据库将"postfix"数据库drop. 或#rm -rf /usr/local/mysql/var/postfix
Q: 还是不能导入
A: 将 "mysql"数据库中"user"表中的"postfix"和"postfixadmin"用户delete

五、安装 cyrus-sasl-2.1.22

先关闭默认安装的sasl
# mv /usr/lib/sasl2 /usr/lib/sasl2.OFF
#tar -zxvf cyrus-sasl-2.1.22.tar
#cd cyrus-sasl-2.1.22
#./configure --disable-anon -enable-plain --enable-login --enable-sql --with-mysql=/usr/local/mysql --enable-sample --with-authdaemond
#make
#make install
更新lib库
# echo "/usr/local/lib" >> /etc/ld.so.conf
# ldconfig
重要
# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
#/usr/sbin/saslauthd -v 查看版本和可以使用的密码验证机制
saslauthd 2.1.22
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap

Q: 提示sasl找不到authdaemon的SOCKET
A:安装SASL的时候最好不要指定安装路径。如果你直径的安装路径的时候,以后安装authlib的时候会出问题。所以以后 安装authlib 的时候也不指定路径 (指定也可以.解决的时候比较繁琐)

六、安装postfix 2.6
如果你的系统上原来有sendmail,先将其停止并将其文件改名
# /etc/init.d/sendmail stop
# chkconfig --level 0123456 sendmail off
# mv /usr/bin/newaliases /usr/bin/newaliases.old
# mv /usr/bin/mailq /usr/bin/mailq.old
# mv /usr/sbin/sendmail /usr/sbin/sendmail.old

开始安装
# groupadd -g 2000 postfix
# useradd -u 2000 -g 2000 -c postfix -d/dev/null -s/sbin/nologin postfix
# groupadd -g 3000 postdrop
# tar zxvf postfix-2.4.6.tar
# cd postfix-2.4.6
# make -f Makefile.init makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl -DHAS_MYSQL -I/usr/local/mysql/include/mysql " AUXLIBS="-L/usr/local/lib -lsasl2 -L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm"

#make
#make install
之后一路回车 postfix OK 了

Q: "[/]"里都没有postfix各功能的目录. postfix找不到你libmysqlclient.so.15
A: # echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf
# ldconfig
或 # ln -s /usr/locl/mysql/lib/nysql/libmysqlclient.so.15 /usr/lib/libmysqlclient.so.15
再 #make install

检验一下sasl是否绑定到了postfix上
#postconf -a
cyrus
dovecot
如果有cyrus说明你已经成功了。

vi /etc/postfix/main.cf
#=====================BASE=========================
myhostname = mail.test.com
mydomain = test.com
myorigin = $mydomain
mydestination = $myhostname localhost localhost.$mydomain
mynetworks = 127.0.0.0/8
inet_interfaces = all

#=====================Vritual Mailbox settings=========================
virtual_mailbox_base = /var/mailbox/
virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:1001
virtual_gid_maps = static:1001
#virtual_transport = maildrop
#virtual_transport = vmail
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1

################## maildrop #############

#mail_owner = maildrop
#mailbox_transport = maildrop
#fallback_transport = maildrop
#maildrop_destination_recipient_limit = 1


######################################


#====================QUOTA========================
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes

#====================SASL========================
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,
reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner=$myhostname ESMTP "Version not Available"
(注意:我上的配置文件里的注释。我去掉了maildrop)

建立/var/mailbox并设置权限
# mkdir /var/mailbox
# chown -R vmail:vmail /var/mailbox
# chmod -R ug+rwx,o-rwx /var/mailbox

建立/etc/postfix/mysql文件夹和MySQL查询配置文件
# mkdir /etc/postfix/mysql
1、vi /etc/postfix/mysql/mysql_virtual_alias_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address

2、vi /etc/postfix/mysql/mysql_virtual_domains_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain
#additional_conditions = and backupmx = '0' and active = '1'

3、vi /etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'

4、vi /etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = '1'

配置 /usr/local/lib/sasl2/smtpd.conf
sasl密码验证机制为authdaemond
# vi /usr/local/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
log_level:3
srp_mda:md5
password_format:crypt
mech_list: PLAIN LOGIN
authdaemond_path: /usr/local/var/spool/authdaemon/socket

检验postfix 是否支持了认证

#telnet localhost 25
ehlo localhost
ehlo localhost
250-mail.test.com
250-PIPELINING
250-SIZE 14336000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
说明 postfix 已经 有 验证 机制了

七、安装Courier-authlib 0.57
新版本的imap不再包含authentication library,必须先安装 Courier authentication library
#tar -zxvf courier-authlib-0.59.3.tar.tar
# cd courier-authlib-0.59.3
# ./configure --with-redhat --with-authmysql=yes --with-mailuser=vmail --with-mailgroup=vmail --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql/
# make
# make install
# make install-configure
重要
# chmod +x /usr/local/var/spool/authdaemon/

# vi /usr/local/etc/authlib/authdaemonrc
authmodulelist="authmysql"
DEBUG_LOGIN=2
(注:打开authdaemon的日志 方便调试。 调试成功之后把2 改成 0)

# mv /usr/local/etc/authlib/authmysqlrc /usr/local/etc/authlib/authmysqlrc.old
备份一下authlib的配置文件。
# vi /usr/local/etc/authlib/authmysqlrc
MYSQL_SERVER localhost
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_DATABASE postfix
MYSQL_USERNAME postfix
MYSQL_PASSWORD postfix
MYSQL_USER_TABLE mailbox
MYSQL_LOGIN_FIELD username
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD '1001'
MYSQL_GID_FIELD '1001'
#MYSQL_HOME_FIELD '/var/mailbox/'
#MYSQL_MAILDIR_FIELD maildir
MYSQL_HOME_FIELD concat('/var/mailbox/')
MYSQL_MAILDIR_FIELD concat(maildir)
MYSQL_NAME_FIELD name
MYSQL_QUOTA_FIELD concat(quota,'S')
MYSQL_WHERE_CLAUSE active='1'
DEFAULT_DOMAIN test.com

Q: 测试时sasl认证经常出问题
A:确认在这个文件中不能用空格键(包括行尾),只能用tab键。确认只使用单引号,比如:'/var/mailbox/','UID','GID'(本文为'1001')
localhost不能用单引号 确认你的/etc/hosts文件中有localhost .编译时如果支持Ipv6可能导致错误 MYSQL_GID_FIELD 和MYSQL_UID_FIELD是maildrop的UID和GID,而不是MySQL的. (网上原话)
Q: webmail登陆不了的原因常和这个文件的这两项MYSQL_HOME_FIELD. MYSQL_MAILDIR_FIELD 有关 我用原文的"#"两项老出问题
A: 我做了很多尝试将此改成#下这两项问题解决了.是路径的问题

# cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
# chmod 755 /etc/rc.d/init.d/courier-authlib
# chkconfig --level 0123456 courier-authlib on
手动启动服务:
# authdaemond start

在postfixadmin中建立一测试帐户

测试smtp
# perl -MMIME::Base64 -e 'print encode_base64("test\@test.com");'
dGVzdC5oaw==
# perl -MMIME::Base64 -e 'print encode_base64("test");'
dGVzdA==

# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 www.test.com ESMTP "Version not Available"
ehlo www.test.com
250-www.test.com
250-PIPELINING
250-SIZE 14336000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
auth login
334 VXNlcm5hbWU6
dGVzdC5oaw==
334 UGFzc3dvcmQ6
dGVzdA==
235 Authentication successful

验证 已经OK 了。如果不成功 #tail -n 20 /var/log/maillog 看里面说什么
Q :Jan 23 16:22:42 mail postfix/smtpd[2676]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
A: 是系统默认使用了nis,你可以设置一下:
原因如下:postconf -d │grep nis
alias_maps = hash:/etc/aliases, nis:mail.aliases
注释掉这行(在"/usr/etc/postfix/main.cf"中)
或设置成:alias_maps = hash:/etc/postfix/aliases
Q: Jan 24 02:29:54 mail postfix/smtpd[8452]: warning: SASL authentication failure:Couldn't find mech logig
Q: Jan 24 02:29:54 mail postfix/smtpd[8452]: warning: localhost[127.0.0.1]: SASL logig authentication failed:nomechanism available
A:
#/usr/local/sbin/authdaemond stop/start
#ln -s /usr/local/sbin/authdaemond /usr/sbin/authdaemond


八、安装courier-imap-4.1.3
#tar -xf courier-imap-4.1.3.tar.tar
#cd courier-imap-4.1.3
# ./configure --prefix=/usr/local/imap --with-redhat --disable-root-check --enable-unicode=utf-8,iso-8859-1,gb2312,gbk,gb18030 --with-trashquota --with-dirsync
#make
#make install
# make install-configure

# vi /usr/local/imap/etc/pop3d
POP3DSTART=YES

# vi /usr/local/imap/etc/imapd
IMAPDSTART=YES

将MAILDIRPATH=Maildir改为
MAILDIRPATH=/var/mailbox/


让imap自启动:
# cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
# chmod 755 /etc/rc.d/init.d/courier-imap
# chmod --add courier-imap
# chkconfig --level 0123456 courier-imap on

测试POP3
# telnet localhost 110
+OK Hello there
user
+OK Password required.
pass test
+OK Logged in.
quit
+OK bye-bye

OK 了 。

九.安装Courier-maildrop 2.0.1
先装pcre
# wget http://optusnet.dl.sourceforge.net/sourcef...cre-6.3.tar.bz2
# tar jxvf pcre-6.3.tar.bz2
# cd pcre-6.3
# ./configure
# make
# make install

# wget http://optusnet.dl.sourceforge.net/sourcef...p-2.0.1.tar.bz2
# tar jxvf maildrop-2.0.1.tar.bz2
# cd maildrop-2.0.1
# ./configure \
--prefix=/usr/local/maildrop \
--enable-sendmail=/usr/sbin/sendmail \
--enable-trusted-users='root vmail' \
--enable-syslog=1 \
--enable-maildirquota \
--enable-maildrop-uid=1001 \
--enable-maildrop-gid=1001 \
--with-trashquota \
--with-dirsync
# make
# make install
# cp /usr/local/maildrop/bin/maildrop /usr/bin
# chmod a+rx /usr/bin/maildrop

运行maildrop -v应该有如下提示信息:
maildrop 2.0.0 Copyright 1998-2005 Double Precision, Inc.
GDBM extensions enabled.
Courier Authentication Library extension enabled.
Maildir quota extension enabled.
This program is distributed under the terms of the GNU General Public
License. See COPYING for additional information.

新建/etc/maildroprc文件
# vi /etc/maildroprc
logfile "/var/mailbox/maildrop.log"
to "$HOME/$DEFAULT"

# chmod a+r /etc/maildroprc

配置Postfix
# vi /etc/postfix/master.cf 将第一项#去掉注,释掉原来的flags项或修改
maildrop unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/local/maildrop/bin/maildrop -w 90 -d ${recipient}

Q: 日志提示maildrop想关错误
A: 第一项前不能有空格.后一项前有空两个空格

由于maildrop没有建立及删除maildir的功能,因此由脚本实现
# vi /etc/sudoers
vmail ALL = NOPASSWD: /usr/sbin/maildirmake.sh , /usr/sbin/maildirdel.sh

新建/usr/sbin/maildirmake.sh文件
# vi /usr/sbin/maildirmake.sh
#!/bin/bash
set -e
if [ ! -d /var/mailbox/$1 ]
then
mkdir /var/mailbox/$1
fi
chown -R vmail:vmail /var/mailbox/$1
cd "/var/mailbox/$1"
/usr/local/imap/bin/maildirmake $2
chown -R vmail:vmail /var/mailbox/$1/$2

新建/usr/sbin/maildirdel.sh文件
# vi /usr/sbin/maildirdel.sh
#!/bin/bash
rm -rf /var/mailbox/$1/$2

# chmod 755 /usr/sbin/maildirmake.sh
# chmod 755 /usr/sbin/maildirdel.sh

更改postfixadmin目录及postfixadmin/admin目录下的create-mailbox.php文件
在这两个文件的$tQuota = $CONF['maxquota'];行下另起加一行(postfixadmin/admin目录下的大概在200行,postfixadmin目录下的大概在209行):
# vi /var/www/postfixadmin/admin/create-mailbox.php (vi /var/www/postfixadmin/create-mailbox.php)
system("sudo /usr/sbin/maildirmake.sh $fDomain ".$_POST['fUsername']);

更改postfixadmin目录及postfixadmin/admin目录下的delete.php文件
在这两个文件的$result = db_query ("SELECT * FROM mailbox WHERE username='$fDelete' AND domain='$fDomain'");行后加几行:
# vi + 93 /var/www/postfixadmin/admin/delete.php (vi +52 /var/www/postfixadmin/delete.php)
$userarray=explode("@",$fDelete);
$user=$userarray[0];
$domain=$userarray[1];
system("sudo /usr/sbin/maildirdel.sh $domain $user");

九.1.测试
启动所有服务
# /etc/init.d/ httpd restart
# /etc/init.d/ mysqld testart
# /etc/sbin/postfix stop/start
# /etc/init.d/courier-authlib restart
# /etc/init.d/courier-imap restart

# ss -nat |grep "LISTEN"
LISTEN 0 0 *:3306
LISTEN 0 0 *:110
LISTEN 0 0 *:143
LISTEN 0 0 *:80
LISTEN 0 0 92.168.0.110:53
LISTEN 0 0 127.0.0.1:53
LISTEN 0 0 *:25

在postfixadmin中建立一测试帐户

测试smtp
# perl -MMIME::Base64 -e 'print encode_base64("test\@test.com");'
dGVzdEB0ZXN0LmNvbQ==
# perl -MMIME::Base64 -e 'print encode_base64("test");'
dGVzdA==

# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 www.test.com ESMTP "Version not Available"
ehlo www.test.com
250-www.test.com
250-PIPELINING
250-SIZE 14336000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
auth login
334 VXNlcm5hbWU6
dGVzdEB0ZXN0LmNvbQ==
334 UGFzc3dvcmQ6
dGVzdA==
235 Authentication successful

测试POP3和IMAP
# telnet localhost 110
+OK Hello there
user
+OK Password required.
pass test
+OK Logged in.
quit
+OK bye-bye

测试maildrop
# maildrop -V 9 -d
maildrop: authlib: groupid=1001
maildrop: authlib: userid=1001
maildrop: authlib: , home=/var/mailbox/, mail=test.com/test/
maildrop: Changing to /var/mailbox/

ctrl+c退出


十.webmail

10.1.安装squirrelmail 1.4.5
下载squirrelmail及中文包
# wget http://keihanna.dl.sourceforge.net/sourcef...l-1.4.5.tar.bz2
# wget http://optusnet.dl.sourceforge.net/sourcef...0050904.tar.bz2
# tar jxvf squirrelmail-1.4.5.tar.bz2 -C /var/www/
# cp /var/www/squirrelmail-1.4.5/ /var/www/squirrelmail
解压中文包
# tar jxvf zh_CN-1.4.5-20050904.tar.bz2 -C /var/www/squirrelmail/

在配置squirrelmail之前先下载三个插件:
Quota Usage Version 1.3
# wget http://www.squirrelmail.org/countdl.php?fi....3-1.2.7.tar.gz
Compatibility Version 2.0.2
# wget http://www.squirrelmail.org/countdl.php?fi...ty-2.0.2.tar.gz
Change MySQL Password Version 3.2
# wget http://www.squirrelmail.org/countdl.php?fi....2-1.2.8.tar.gz

把这三个插件解压到squirrelmail的plugin目录下
# tar zxvf quota_usage-1.3-1.2.7.tar.gz -C /var/www/squirrelmail/plugins/
# tar zxvf compatibility-2.0.2.tar.gz -C /var/www/squirrelmail/plugins/
# tar zxvf change_mysqlpass-3.2-1.2.8.tar.gz -C /var/www/squirrelmail/plugins/
第一个插件是用来显示邮箱的使用情况的;第二个和第三个插件是用来修改密码的。
如果不想装这些插件,请跳过。

配置Quota Usage
# cd /var/www/squirrelmail/plugins/quota_usage
# cp config.php.sample config.php

配置Change MySQL Password
# cd /var/www/squirrelmail/plugins/change_mysqlpass
# cp config.php.sample config.php
# vi config.php
更改如下几个变量:
$mysql_database = 'postfix';
$mysql_table = 'mailbox';
$mysql_userid_field = 'username';
$mysql_password_field ='password';
$mysql_manager_id = 'postfix';
$mysql_manager_pw = 'postfix';
$mysql_unixcrypt = 0;
$mysql_MD5crypt = 1;
$use_ssl_for_password_change = 0;

配置squirrelmail
# cd /var/www/squirrelmail
# ./configure
进入10. Languages
把1. Default Language : 的en_US改成zh_CN。
进入8. Plugins,添加这三个插件
或直接编辑 /var/www/squirrelmail/config/config.php在其中更改donmail及目录路径等
# chown -R vmail:vmail /var/www/squirrelmail/data/
# chmod -R 730 /var/www/squirrelmail/data/

打开浏览器输入http://yourdomain/squirrelmail/,用登陆,你将会在屏幕的左上角看到邮箱的使用情况,你还会看到一条警告信息:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/squirrelmail/plugins/change_mysqlpass/functions.php on line 129
这是由于数据库结构不一致造成的,你只要把functions.php中的129行注释调即可(在行首加//)
再次登陆OK!
恭喜你完成了简单而功能齐全的邮件服务器!


附: 此实验花了好几天才做成功.
本文档也是按原载文再结合很多文档经过多次操作修改完成.所以按照此文件一步步做可能也会遇到一些问题.
在配置过程中遇到了很多问题.没有急时一一列出
如各位在配置过程中遇到什么新问题且能查找出原因,请将问题及解决方法返回给我.谢谢!
还有将squirrelmail换成iGENUS我配了很长时间都没有成功.如有哪位同事配出来了请和我说一声!