安装extman:

tar -zxvf extman-0.2.2.tar.gz
mv extman-0.2.2 /var/www/extsuite/extman
cd /var/www/extsuite/extman
vi webman.cf
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_DEFAULT_GID = 2525 //即postfix组gid
更改目录的权限:
chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
chown -R postfix.postfix /var/www/extsuite/extman/cgi/
mkdir /tmp/extman
chown -R postfix:postfix /tmp/extman
配置apache:

<VirtualHost *>
         ServerAdmin admin@upkiller.com      //管理员邮件
         ServerName   upkiller.com     //域名
         ServerAlias www.upkiller.com       //别名
         DocumentRoot /var/www/extsuite/extmail/html //网站目录
         ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi   //脚本执行别名
         Alias        /extmail   /var/www/extsuite/extmail/html     //别名
         ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
         Alias        /extman /var/www/extsuite/extman/html
         SuexecUserGroup postfix postfix               //切换到postfix帐户运行
        <Directory /var/www/extsuite>         //目录权限
        Options Indexes FollowSymLinks        //允许符号链接,访问不在本目录下的文件
        AllowOverride None                    //禁止读取.htaccess
        Order allow,deny                      //指定先执行Allow访问规则,再执行Deny访问规则
        Allow from all                        //允许访问所有
        </Directory>
</VirtualHost>
------------------------------------------------------------------------------
安装extman的图形日志:
1,在首先在http://search.cpan.org
搜索:Time::HiRes和File::Tail:并下载
http://oss.oetiker.ch/rrdtool/pub/?M=D 下载rrdtool-1.2.23.tar.gz
安装Time::HiRes
tar zxvf Time-HiRes-1.9707.tar.gz
cd Time-HiRes-1.9707
perl Makefile.PL
make
make test
make install
安装File::Tail
tar zxvf File-Tail-0.99.3.tar.gz
cd File-Tail-0.99.3
perl Makefile.PL
make
make test
make install
安装rrdtool-1.2.23
tar zxvf rrdtool-1.2.23.tar.gz
cd rrdtool-1.2.23
(需要libart_lgpl-devel,libpng-devel,tcl-devel,freetype,libpng)
./configure --prefix=/usr/local/rrdtool
make
make install
错误:I found a copy of pkgconfig, but there is no freetype2.pc
cd /usr/src/freetype-2.2.1
find . -name "*.pc
cp builds/unix/freetype2.pc /usr/lib/pkgconfig/

复制mailgraph_ext到/usr/local,并启动之
cp -r /var/www/extsuite/extman/addon/mailgraph_ext   /usr/local  
/usr/local/mailgraph_ext/mailgraph-init   start
启动报错:
Can't locate RRDs.pm in @INC.....
解决方法:
find /usr -name "RRDs.pm"
ln -sv /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/RRDs.pm    /usr/lib/perl5/5.8.5
再启动:
Can't locate loadable ojbect for module RRDs
解决:
ln -sv /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/auto/RRDs/RRDs.so    /usr/lib/perl5/5.8.5/i386-linux-thread-multi/
再启动ok
(如果碰到少别的模块都可以用查找链接这种方法解决,找不到就是没安装咯,一个是pm模块,一个是so库)
/usr/local/mailgraph_ext/qmonitor-init   start //启动ok
打开extman后台管理,打开图形日志,没报错就ok啦。
再加入开机启动:
echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.local
-----------------------------------------------------------------------
Extman FAQ:
1,extman默认登录密码:
默认管理帐号为:root@extmail.org   密码为:extmail*123*
2,第一次配置好extmail打开浏览器提示:
Unix::Syslog not found, please install it first! (in cleanup) Undefined subroutine &Ext::Logger::do_closelog called at /var/www/extsuite/extmail/libs/Ext/Logger.pm line 87.
没装perl-Unix-Syslog包,
安装perl-Unix-Syslog-0.100-1hzq.i386.rpm搞定
或是到http://search.cpan.org搜索Syslog下载一个Unix-Syslog-0.100.tar.gz
tar zxvf Unix-Syslog-0.100.tar.gz
cd Unix-Syslog-0.100
perl Makefile.PL
make
make install
3,install_driver(mysql) failed: Can't locate DBD/mysql.pm in
搜索DBD-mysql-4.005.tar.gz下载,安装,结果提示如下
4,之后提示Internal Server Error:
tail -f error_log
/usr/bin/perl: symbol lookup error: /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql.so: undefined symbol: DBIc_TRACE_LEVEL
//肯定是DBD-MYSQL版本不兼容问题:
find /usr/lib -name "mysql.so" -exec rm {} \;
http://search.cpan.org/dist/DBD-mysql/下载:DBD-mysql-3.0002_4.tar.gz
perl Makefile.PL
make
make install
(再打开ok)
如果还是显示内部服务器错误,apache的error_log还提示:
suexec policy violation: see suexec log for more details
Premature end of script headers: index.cgi
提示查看su日志:
----------------------------------
关于suexec的FAQ
1.出现以下错误   command not in docroot
编译的时候加入--with-suexec-docroot     以后虚拟主机运行suexec的目录必须包含指定的目录里,通过suexec -V 可以察看docroot目录是哪儿
2.出现以下错误   user mismatch (daemon instead of www)
编译的时候加入--with-suexec-caller=daemon   默认是www,但一般apache的运行用户是nobody或者daemon,这里我们是httpd2.2.2,用户是daemon,所以指定这个参数,否则suexec不能被运行。
3.出现以下错误   cannot run as forbidden uid (1001/index.cgi)
在虚拟主机配置SuexecUserGroup时,指定的用户和组,必须高于--with-suexec-uidmin --with-suexec-gidmin 指定的用户uid和gid,否则被限制使用。
------------------------------------------------
编译Apache的时候要加上:
   --enable-suexec \                     
   --with-suexec-caller=daemon \
   --with-suexec-docroot=/var/www/extsuite/
临时用postfix,再去su:
5,又提示:DBI connect('database=extmail;host=localhost;mysql_socket=/var/lib/mysql/mysql.sock',
'extmail',...)failed: Can't connect to local MySQL server
vi /var/www/extsuite/extmail/webmail.cf
改:SYS_MYSQL_SOCKET = /tmp/mysql.sock
vi /var/www/extsuite/extman/webman.cf (同上)
(再打开ok)
6,Can't open /tmp/extman//sid_8519f707216994462c48dcd98b655843, No such file or directory
mkdir /tmp/extman
chown -R postfix:postfix /tmp/extman
7,进入extman无法显示校验码图片:
tail -f error_log
BEGIN failed--compilation aborted at /var/www/extsuite/extman/libs/Ext/GD.pm line 14
perl Makefile.PL
提示gd装在哪/usr/local/gd2/lib
(选图片支持)
Where is libgd installed? [/usr/lib] /usr/local/gd2
Build JPEG support? [y] y
Build PNG support? [y] y
Build FreeType support? [y] y
Build GIF support? [y] y
Build support for animated GIFs? [y] y
Build XPM support? [y] n

make
make install
错误:cannot find -lpng
ln -vs /usr/local/libpng2/lib/* /usr/lib
错误:cannot find -lfreetype
ln -vs /usr/local/freetype2/lib/* /usr/lib
错误:cannot find -ljpeg
ln -vs /usr/local/jpeg6/lib/* /usr/lib
再重新make clean
perl Makefile.PL (成功)
或是:
extman登录不要校验码:
在 webman.cf 将 SYS_CAPTCHA_ON=0 即可,要重启 Apache

8,新建两个域,各建帐号测试发信:

测试帐号和密码是否正常:
/usr/local/courier-authlib/sbin/authtest user1@rohto.com.cn user1
变更密码;
./authtest -s localhost user1@rohto.com.cn user user1
错误FAQ:Can't chdir to /var/mailbox/rohto.com.cn/user1/Maildir/, No such file or directory
查看extman的:
SYS_MAILDIR_BASE = /var/mailbox
配置是否正确,删除域名再重建,在新建用户的时候会自动在/var/mailbox/下创建该用户的域名和邮件目录

登入extmail进行各种发信测试:
发给自己
发给同域帐号
发给不同域帐号
发给163收信
用163收信给自己
再使用outlook/foxmail进行如上测试:
----------------------------------
通过日志分析发信过程:
tail -f /var/log/maillog
成功的日志如下:
postfix/pickup[2215]: 5705EA885D: uid=255 from=<user1@upkiller.com>
postfix/cleanup[3267]: 5705EA885D: message-id=<20070922224616.5705EA885D@mail.upkiller.com>
postfix/qmgr: 5705EA885D: from=<user1@upkiller.org>, size=515,nrcpt=1 (queue active)
postfix/virtual[3271]: 5705EA885D: to=<upkiller@163.org>, relay=mx.mail.163.split.netease.com ,delay=0.13,delays=
0.1/0.02/0.0.01,dsn=2.0.0,status=send (delivered to maildir)
postfix/qmgr[2214]: 5705EA885D: removed
发信错误FAQ:
1,不能发送邮件:
warning: do not list domain upkiller.com in BOTH mydestination and virtual_mailbox_domains
明显是指这个域名不在mydestination许可的列表
解决方法:
在有多域的服务器上直接把mydestination选项在/etc/postfix/main.cf注释掉:

2,虚拟域不能发送邮件给自己:
Sep 28 14:01:10 rohto postfix/local[2377]: 07AC332E69: to=<user2@xxxx.com.cn>, relay=local, delay=0.71, delays=0.41/0.16/0/0.14, dsn=5.1.1, status=bounced (unknown user: "user2")
1)首先确定:
extman/webman.cf文件中:
SYS_DEFAULT_GID = 2525
修改后进入/var/mailbox/domain.com.cn中rm -rf *
2)原来是在main.cf文件中myhostname与mydomain不能一样,要不然
虚拟域和main.cf中设的域名一样就会出现问题:(kao)
myhostname = xxx.com.cn
mydomain = xxxx.com.cn
修改如下:
myhostname = mail.xxx.com.cn
mydomain = xxxx.com.cn

3,两台extmail互发邮件拒绝:
Recipient address rejected: Try again, see http://bl.extmail.org/cgi/why?greylist (in
reply to RCPT TO command)
//接收地址拒绝,再次尝试,查看http://bl.extmail.org/cgi/why?greylist
上面的解释:
您的主机将被greylist临时封锁 (300 秒
这是您第一次发信给收件人,请隔一段时间重试
前后两次发信间隔小于阀值 (300秒)
等待300秒再发送,没有问题。
解决办法:
修改:/usr/local/slockd/config/whitelist
4,无法向其它服务器发送邮件提示:
Host or domain name not found. Name service error for name=163.com type=MX: Host not found, try again
mail服务器resolv.conf未设好
5,向163发信提示:
http://mail.163.com/help/help_spam_16.htm (in reply to end of DATA command)

反病毒
反垃圾

------------------------------------
小技巧:
1,反解不存在的机器将被拦截:
smtpd_client_restrictions = reject_unknown_client ( 如果是postfix 2.3或以上,则是reject_unknown_client_hostname)
2,日志分析技巧:
1)postfix日志成功接收到邮件:(交货到邮件目录)
cat /var/log/maillog |grep "delivered to maildir"
cat /var/log/maillog |grep "delivered to maildir" | egrep -o "(\w+)([@]{1}\w+[.]{1,})(\w+)"
2)取当天日志:
cat /var/log/maillog | egrep "`data | awk "`'{print ""$2" "$3""}'`"
3)取指定日期的错误日志:
cat /var/log/maill | grep "^Sep\ 25" | egrep "reject|warning|error|fatal|panic" | more