下面列出所需相关软件包:

httpd-2.2.9.tar.gz 安装源码包apache

mysql-5.0.56.tar.gz 安装源码包mysql

php-5.2.6.tar.bz2 安装php软件

postfix-2.4.6.tar.gz postfix主程序

postfix-2.4.6-vda-ng.patch.gz postfix的补丁包

dovecot-1.1.4.tar.gz IMAP和POP3邮件服务器软件

squirrelmail-1.4.13.tar.bz2 web界面邮件管理

extman-0.2.5.tar.gz 邮件后台管理程序

extmail-1.0.5.tar.gz web界面邮件管理

courier-authlib-0.60.2.tar.bz2 SMTP发信认证

Unix-Syslog-1.1.tar.gz

DBI-1.607.tar.gz

DBD-mysql-4.011.tar.gz 以上三个包为extmail的倚赖包

GD-2.41.tar.gz

File-Tail-0.99.3.tar.gz

rrdtool-1.2.23-3.el5.i386.rpm

rrdtool-perl-1.2.23-3.el5.i386.rpm 以上四个包为extman的倚赖包

下面开始进行postfix邮件服务器的搭建:

以上软件包分别上传到服务器的“/”(root的home目录下)下:

一:安装apache软件:

下面我们将把所有需要的安装包解压到/usr/local/src/下面以方便我们统一管理维护

[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/httpd-2.2.19/

[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite

[root@localhost httpd-2.2.19]# make

[root@localhost httpd-2.2.19]# make install

这里我们并没有将Suexec编译进apache中去,提到这个的原因是因为后面我们装postfix时候的后台管理extman是通过CGI的方式来调用程序的,如果不启用Suexec的话那么就会限制其他用户调用CGI程序,但考虑到启用Suexec的风险我们在此就不启用它了。(启用方式:--enable-suexec –with-suexec-caller=daemon –with-suexec-docroot=/usr/local/apache2/htdocs)

二:安装mysql软件:

添加mysql用户,如果安装系统时候已经装过mysql会提示用户已存在,建议在安装前先卸载掉系统自带的mysql,卸载完成后必须重启,否则新装的mysql会无法启动,提示错误信息3306端口被占有:

[root@localhost ~]# useradd -M -s /sbin/nologin mysql

[root@localhost ~]# tar -zxvf mysql-5.1.45.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/mysql-5.1.45/

[root@localhost mysql-5.1.45]# ./configure --prefix=/usr/local/mysql

[root@localhost mysql-5.1.45]# make

[root@localhost mysql-5.1.45]# make install

配置mysql:

复制主配置文件:

[root@localhost mysql-5.1.45]# cp support-files/my-medium.cnf /etc/my.cnf

[root@localhost mysql-5.1.45]# /usr/local/mysql/bin/mysql_install_db --user=mysql

初始化数据库:

[root@localhost mysql-5.1.45]# chown -R root:mysql /usr/local/mysql

[root@localhost mysql-5.1.45]# chown -R mysql /usr/local/mysql/var

添加库文件路径:

[root@localhost mysql-5.1.45]# echo "/usr/local/mysql/lib/mysql/" >> /etc/ld.so.conf

刷新库文件搜索路径:

[root@localhost mysql-5.1.45]# ldconfig

后台安全启动 (如果显示启动并且卡住不动按回车):

[root@localhost mysql-5.1.45]# /usr/local/mysql/bin/mysqld_safe --user=mysql &

复制启动脚本:

[root@localhost mysql-5.1.45]# cp support-files/mysql.server /etc/init.d/mysqld

赋予脚本执行权限:

[root@localhost mysql-5.1.45]# chmod +x /etc/init.d/mysqld

添加到系统自动启动服务中:

[root@localhost mysql-5.1.45]# chkconfig --add mysqld

默认启动mysql:

[root@localhost mysql-5.1.45]# chkconfig mysqld on

查看mysql在什么级别启动或者关闭:

[root@localhost mysql-5.1.45]# chkconfig --list mysqld

设置系统全局的环境变量PATH值,方便使用mysql数据库命令:

[root@localhost mysql-5.1.45]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

重新读取:

[root@localhost ~]# . /etc/profile

三:安装php软件

[root@localhost ~]# tar -jxvf php-5.3.2.tar.bz2 -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/php-5.3.2/

[root@localhost php-5.3.2]# ./configure --prefix=/usr/local/php5 --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5

[root@localhost php-5.3.2]# make

[root@localhost php-5.3.2]# make install

复制配置文件:

[root@localhost php-5.3.2]# cp php.ini-production /usr/local/php5/php.ini

修改apache服务的主配置文件使其支持php:

[root@localhost php-5.3.2]# vim /usr/local/apache2/conf/httpd.conf

310 AddType application/x-httpd-php .php

167 DirectoryIndex index.php index.html

四:测试php是否与apache整合成功:

[root@localhost php-5.3.2]# vim /usr/local/apache2/htdocs/test.php

<?php

phpinfo();

?>

[root@localhost ~]# /usr/local/apache2/bin/apachectl start

在浏览器中输入http://192.168.2.1/test.php 看到下图表示跟apache服务整合成功

clip_image002

Mysql测试:

编辑测试脚本:

[root@localhost ~]# vim /usr/local/apache2/htdocs/testdb.php

<?php

$link=mysql_connect('localhost', 'root', '');

If (!$link) echo "Fail!!!";

else echo "Success!!!";

mysql_close();

?>

在浏览器中输入网址http://192.168.2.1/testdb.php 看到下图表示跟mysql服务整合成功

clip_image004

五: 安装postfix软件

安装postfix之前首先停止掉系统自带的sendmail软件:

[root@localhost ~]# service sendmail stop

[root@localhost ~]# chkconfig --level 35 sendmail off

编译安装postfix软件

[root@localhost ~]# groupadd -g 1200 postdrop

[root@localhost ~]# groupadd -g 1000 postfix

[root@localhost ~]# useradd -M -u 1000 -g postfix -G postdrop -s /sbin/nologin postfix

[root@localhost ~]# tar -zxvf postfix-2.6.2.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/

[root@localhost src]# cd postfix-2.6.2

[root@localhost postfix-2.6.2]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'

[root@localhost postfix-2.6.2]# make

进行安装,安装过程中会出现互动提问,直接选择默认设置即可。

[root@localhost postfix-2.6.2]# make install

六:配置postfix

postfix主配文件修改

[root@localhost postfix-2.6.2]# vim /etc/postfix/main.cf

75 myhostname = mail.wisefund.com主机名

83 mydomain = wisefund.com邮件域名

99 myorigin = $mydomain外发邮件时发件人地址中的邮件域名

113 inet_interfaces = all 默认监听端口为所有

160 mydestination = $myhostname, $mydomain可接收的邮件地址中的域名

412 home_mailbox = Maildir/ 邮件存储位置格式

[root@localhost postfix-2.6.2]# postfix check 检查配置

[root@localhost postfix-2.6.2]# postfix start 启动

Smtp发送邮件测试

邮件本地账户管理:

[root@localhost ~]# groupadd mailusers

[root@localhost ~]# useradd -g mailusers -s /sbin/nologin user1

[root@localhost ~]# passwd user1

[root@localhost ~]# useradd -g mailusers -s /sbin/nologin test

[root@localhost ~]# passwd test

SMTP发送邮件测试:

[root@localhost ~]# telnet localhost 25

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

220 mail.wisefund.com ESMTP Postfix

Hello localhost宣告客户端主机地址

502 5.5.2 Error: command not recognized

220 mail.wisefund.com ESMTP Postfix

502 5.5.2 Error: command not recognized

MAIL FROM:test@wisefund.com 发信人地址

250 2.1.0 Ok

RCPT TO:user1@wisefund.com 收信人地址

250 2.1.5 Ok

DATA

354 End data with <CR><LF>.<CR><LF>

Subject:hello 标记开始写信

hello!!!!

. “点”表示信件结束

250 2.0.0 Ok: queued as ABDE418421C

quit 退出

221 2.0.0 Bye

Connection closed by foreign host.

查看接收到的邮件,按tab键补齐:

clip_image006

Dovecot 邮局软件安装(提供pop3/imap4协议)

安装Dovecot

[root@localhost ~]# useradd -M -s /sbin/nologin dovecot

[root@localhost ~]# tar -zxvf dovecot-1.1.4.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/dovecot-1.1.4/

[root@localhost dovecot-1.1.4]# ./configure --sysconfdir=/etc --with-mysql

[root@localhost dovecot-1.1.4]# make

[root@localhost dovecot-1.1.4]# make install

安装完成,

配置复制主配置文件:

[root@localhost dovecot-1.1.4]# cp /etc/dovecot-example.conf /etc/dovecot.conf

[root@localhost dovecot-1.1.4]# vim /etc/dovecot.conf

24 protocols = imap pop3 指定邮局协议

48 disable_plaintext_auth = no 允许明文密码认证

88 ssl_disable = yes 禁用SSL机制

209 mail_location = maildir:~/Maildir设置邮件存储格式和位置

建pam认证文件:

[root@localhost dovecot-1.1.4]# vim /etc/pam.d/dovecot

auth required pam_nologin.so

auth include system-auth

account include system-auth

session include system-auth

启动:

[root@localhost dovecot-1.1.4]# /usr/local/sbin/dovecot -c /etc/dovecot.conf

POP3邮件接收测试

[root@localhost ~]# telnet localhost 110

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

+OK Dovecot ready.

user user1

+OK

pass 123

+OK Logged in.

list

+OK 1 messages:

1 489

.

retr 1

+OK 489 octets

Return-Path: <test@wisefund.com>

X-Original-To: user1@wisefund.com

Delivered-To: user1@wisefund.com

Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])

by mail.wisefund.com (Postfix) with SMTP id ABDE418421C

for <user1@wisefund.com>; Tue, 10 Apr 2012 17:56:18 +0800 (CST)

Subject:hello

Message-Id: <20120410095652.ABDE418421C@mail.wisefund.com>

Date: Tue, 10 Apr 2012 17:56:18 +0800 (CST)

From: test@wisefund.com

To: undisclosed-recipients:;

hello!!!!

.

quit

+OK Logging out.

Connection closed by foreign host.

安装Webmail软件

7.squirrelmail安装

[root@localhost ~]# tar -jxvf squirrelmail-1.4.19.tar.bz2 -C /usr/local/apache2/htdocs/

[root@localhost ~]# cd /usr/local/apache2/htdocs/

[root@localhost htdocs]# mv squirrelmail-1.4.19 webmail

8.配置webmail

[root@localhost ~]# cd /usr/local/apache2/htdocs/webmail/

[root@localhost webmail]# mkdir -p attach data

[root@localhost webmail]# chown -R daemon:daemon attach/ data/

[root@localhost webmail]# chmod 730 attach/

[root@localhost webmail]# cp config/config_default.php config/config.php

创建配置文件:

[root@localhost webmail]# vim config/config.php

231 $imap_server_type = 'dovecot';

499 $data_dir = '/usr/local/apache2/htdocs/webmail/data/';

517 $attachment_dir = '/usr/local/apache2/htdocs/webmail/attach/';

1012 $squirrelmail_default_language = 'zh_CN';

1027 $default_charset = 'zh_CN.UTF-8';

118 $domain = 'wisefund.com';

重启 apache 服务:

[root@localhost webmail]# /usr/local/apache2/bin/apachectl restart

客户端IE地址栏中输入 http://mail.wisefund.com/webmail (前提mail.wisefund.com可以被解析,否则用ip)即可看见下图:

clip_image008

到此我们的postfix+webmail已经安装完成,但是为了使我们更好的管理维护邮件服务器的前端与后台接下来我们来安装extmail和extman以便实现我们的需求。

初始化 extman 软件

 数据库脚本

[root@localhost ~]# service mysqld restart

[root@localhost ~]# tar -zxvf extman-0.2.5.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/extman-0.2.5/docs/

[root@localhost docs]# mysql -u root -p < extmail.sql

脚本导入数据库的时候会询问密码,默认情况下root用户密码为空:

[root@localhost docs]# mysql -u root -p &lt;init.sql

配置 Postfix

[root@localhost postfix-2.6.2]# postconf -m |grep mysql

mysql(这一步很重要,虽然不影响接下来的安装,但是在extmail时,发送邮件会出错,导致邮件无法发送和接收,此时就要卸载postfix,然后重新编译安装)

修改配置文件

[root@localhost docs]# vim /etc/postfix/main.cf

160 #mydestination = $myhostname, $mydomain该行需要注释掉

649 virtual_mailbox_base = /mailbox 指定虚拟邮箱存储目录的路径起点

650 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf指定虚拟邮件用户对应的别名文件位置

651 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf指定记录虚拟邮箱地址与存储位置对应关系的映射文件位置

652 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf设置postfix服务器可以接收的虚拟邮件域的域名

653 virtual_uid_maps = static:1000设置所有虚拟邮件用户映射的本地用户的UID号

654 virtual_gid_maps = static:1000设置所有虚拟邮件用户映射的本地组的GID 号

[root@localhost docs]# cd /usr/local/src/extman-0.2.5/docs/

在上面的三行配置中指定了这三个文件:

[root@localhost docs]# cp mysql_virtual_* /etc/postfix/

9.虚拟用户设置SMTP发信认证

软件安装

注意:确认系统中的rpm格式的mysql 软件被卸载

[root@localhost ~]# tar -jxvf courier-authlib-0.62.4.tar.bz2 -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/courier-authlib-0.62.4/

[root@localhost courier-authlib-0.62.4]# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-redhat --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql

[root@localhost courier-authlib-0.62.4]# make

[root@localhost courier-authlib-0.62.4]# make install

[root@localhost courier-authlib-0.62.4]# make install-configure

添加courier-authlib的库文件路径

[root@localhost ~]# vim /etc/ld.so.conf

/usr/local/courier-authlib/lib/courier-authlib/

[root@localhost ~]# ldconfig

修改authdaemonrc主配置文件

[root@localhost ~]# cd /usr/local/courier-authlib/etc/authlib/

[root@localhost authlib]# cp authdaemonrc authdaemonrc.bak

[root@localhost authlib]# vim authdaemonrc

27 authmodulelist="authmysql"

34 authmodulelistorig="authmysql"

[root@localhost authlib]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon

修改authmysqlrc 文件

[root@localhost ~]# cd /usr/local/courier-authlib/etc/authlib/

[root@localhost authlib]# cp authmysqlrc authmysqlrc.bak

[root@localhost authlib]# vim authmysqlrc

26 MYSQL_SERVER localhost 数据库服务器位置

27 MYSQL_USERNAME extmail 数据库管理员账户

28 MYSQL_PASSWORD extmail 数据库管理员账户密码

50 MYSQL_SOCKET /tmp/mysql.sock 文件位置

69 MYSQL_DATABASE extmail 虚拟用户数据库

84 MYSQL_USER_TABLE mailbox 从mailbox表获得邮件账户信息

93 MYSQL_CRYPT_PWFIELD password 从password字段获得账户密码

114 MYSQL_UID_FIELD uidnumber 从uidnumber字段获得映射的本地用户UID

120 MYSQL_GID_FIELD gidnumber 从gidnumber字段获得映射的本地组GID

129 MYSQL_LOGIN_FIELD username 从username字段获得账户名称,带@后缀

134 MYSQL_HOME_FIELD concat('/mailbox/',homedir) 合并出用户的宿主目录路径

151 MYSQL_MAILDIR_FIELD concat('/mailbox/',maildir) 合并出用户的邮件存储路径

复制脚本,启动服务

[root@localhost authlib]# cd /usr/local/src/courier-authlib-0.62.4/

[root@localhost courier-authlib-0.62.4]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib

[root@localhost courier-authlib-0.62.4]# chmod 755 /etc/rc.d/init.d/courier-authlib

[root@localhost courier-authlib-0.62.4]# chkconfig --level 35 courier-authlib on

[root@localhost courier-authlib-0.62.4]# service courier-authlib start

[root@localhost courier-authlib-0.62.4]# ps aux |grep courier-authlib

10. 修改Cyrus sasl 设置

[root@localhost ~]# vim /usr/lib/sasl2/smtpd.conf

pwcheck_method:authdaemond

authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket

11. 修改Dovecot配置

修改Dovecot

[root@localhost ~]# vim /etc/dovecot.conf

209 mail_location = maildir:/mailbox/%d/%n/Maildir

900 passdb sql {

902 args = /etc/dovecot-mysql.conf

903 }

963 userdb sql {

965 args = /etc/dovecot-mysql.conf

966 }

建立数据查询配置文件

[root@localhost ~]# vim /etc/dovecot-mysql.conf

driver = mysql

connect = host=localhost dbname=extmail user=extmail password=extmail

数据库中存储的密码串的加密算法:

default_pass_scheme = CRYPT

查询用户密码的语句:

password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = ‘%u’

查询用户身份语句:

user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = ‘%u’

12.建立虚拟用户

建立邮箱目录并调整权限

[root@localhost ~]# mkdir -p /mailbox/extmail.org/postmaster/Maldir

[root@localhost ~]# cd /mailbox/extmail.org/postmaster/Maldir/

[root@localhost Maldir]# chown -R postfix:postfix /mailbox

启动服务

[root@localhost Maldir]# dovecot

虚拟用户测试

确认authlib服务

[root@localhost ~]# /usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail

成功提示信息:

clip_image010

13.ExtMail平台

平台安装

首先安装三个依赖包:(以下三个包在编译安装过程可能会提示 警告信息 隐式函数 计算出的变量值未被使用等,只要没有error信息就一切ok)

[root@localhost ~]# tar -zxvf Unix-Syslog-1.1.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/Unix-Syslog-1.1/

[root@localhost Unix-Syslog-1.1]# perl Makefile.PL

[root@localhost Unix-Syslog-1.1]# make

[root@localhost Unix-Syslog-1.1]# make install

[root@localhost ~]# tar -zxvf DBI-1.616.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/DBI-1.616/

[root@localhost DBI-1.616]# perl Makefile.PL

[root@localhost DBI-1.616]# make

[root@localhost DBI-1.616]# make install

[root@localhost ~]# tar -zxvf DBD-mysql-4.020.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/DBD-mysql-4.020/

[root@localhost DBD-mysql-4.020]# perl Makefile.PL

[root@localhost DBD-mysql-4.020]# make

[root@localhost DBD-mysql-4.020]# make install

安装ExtMail:

[root@localhost ~]# tar -zxvf extmail-1.0.5.tar.gz -C /usr/local/apache2/htdocs/

[root@localhost ~]# cd /usr/local/apache2/htdocs/

[root@localhost htdocs]# mv extmail-1.0.5 extmail

[root@localhost htdocs]# cd extmail

[root@localhost extmail]# chown -R postfix:postfix cgi

[root@localhost extmail]# cp webmail.cf.default webmail.cf

修改配置文件

[root@localhost extmail]# cd /usr/local/apache2/htdocs/extmail/

[root@localhost extmail]# vim webmail.cf

2 SYS_CONFIG = /usr/local/apache2/htdocs/extmail/ 程序根目录

5 SYS_LANGDIR = /usr/local/apache2/htdocs/extmail/lang 语言包文件目录

8 SYS_TEMPLDIR = /usr/local/apache2/htdocs/extmail/html 系统模版目录

112 SYS_MAILDIR_BASE = /mailbox 邮件存储目录

124 SYS_MYSQL_USER = extmail 访问mysql数据库的用户

125 SYS_MYSQL_PASS = extmail 访问mysql数据库的用户的密码

126 SYS_MYSQL_DB = extmail 使用数据库的名称

127 SYS_MYSQL_HOST = localhost 数据库服务器地址

128 SYS_MYSQL_SOCKET = /tmp/mysql.sock 数据库套接文件位置

修改apache服务,添加虚拟主机

[root@localhost extmail]# vim /usr/local/apache2/conf/httpd.conf

66 User postfix

67 Group postfix

411 NameVirtualHost *:80

412 &lt;VirtualHost *:80>

413 ServerName mail.wisefund.com

414 DocumentRoot /usr/local/apache2/htdocs/extmail/html/

415 ScriptAlias /extmail/cgi/ "/usr/local/apache2/htdocs/extmail/cgi/"

416 Alias /extmail "/usr/local/apache2/htdocs/extmail/html/"

417 </VirtualHost>

这里由于前面我们并没有启用Suexec 所以我们没有在虚拟主机中添加 SuexecUerGroup postfix postfix

重启apache服务:

[root@localhost extmail]# /usr/local/apache2/bin/apachectl restart

14:Extman平台

安装包

现安装四个依赖包:

[root@localhost ~]# tar -zxvf GD-2.46.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/GD-2.46/

[root@localhost GD-2.46]# perl Makefile.PL

[root@localhost GD-2.46]# make

[root@localhost GD-2.46]# make install

[root@localhost ~]# tar -zxvf File-Tail-0.99.3.tar.gz -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/File-Tail-0.99.3/

[root@localhost File-Tail-0.99.3]# perl Makefile.PL

[root@localhost File-Tail-0.99.3]# make

[root@localhost File-Tail-0.99.3]# make install

[root@localhost ~]# rpm -ivh rrdtool-1.2.23-3.el5.i386.rpm

[root@localhost ~]# rpm -ivh rrdtool-perl-1.2.23-3.el5.i386.rpm

[root@localhost ~]# tar -zxvf extman-0.2.5.tar.gz -C /usr/local/apache2/htdocs/

[root@localhost ~]# cd /usr/local/apache2/htdocs/

[root@localhost htdocs]# mv extman-0.2.5 extman

[root@localhost htdocs]# cd extman

[root@localhost extman]# chown -R postfix:postfix cgi

临时回话保存目录:

[root@localhost extman]# mkdir /tmp/extman

[root@localhost extman]# chown -R postfix:postfix /tmp/extman

修改配置文件

[root@localhost extman]# vim /usr/local/apache2/htdocs/extman/webman.cf

2 SYS_CONFIG = /usr/local/apache2/htdocs/extman/ 程序根目录

5 SYS_LANGDIR = /usr/local/apache2/htdocs/extman/lang 语言包文件目录

8 SYS_TEMPLDIR = /usr/local/apache2/htdocs/extman/html 系统模版目录

12 SYS_MAILDIR_BASE = /mailbox 邮件数据存放路径

127 SYS_MYSQL_USER = webman 访问mysql数据库的用户

128 SYS_MYSQL_PASS = webman 访问mysql数据库的用户的密码

129 SYS_MYSQL_DB = extmail 使用的数据库名称

130 SYS_MYSQL_HOST = localhost 数据库服务器地址

131 SYS_MYSQL_SOCKET = /tmp/mysql.sock 数据库套接文件位置

调整apache主配文件。添加extman相关目录别名

[root@localhost extman]# vim /usr/local/apache2/conf/httpd.conf

411 NameVirtualHost *:80

412 <VirtualHost *:80>

413 ServerName mail.wisefund.com

414 DocumentRoot /usr/local/apache2/htdocs/extmail/html/

415 ScriptAlias /extmail/cgi/ "/usr/local/apache2/htdocs/extmail/cgi/"

416 Alias /extmail "/usr/local/apache2/htdocs/extmail/html/"

417 ScriptAlias /extman/cgi "/usr/local/apache2/htdocs/extman/cgi/"

418 Alias /extman "/usr/local/apache2/htdocs/extman/html/"

419 </VirtualHost>

重启apache服务:

[root@localhost extman]# /usr/local/apache2/bin/apachectl restart

 现在在客户端访问

http://mail.wisefund.com 就可以看见ExtMail的登录界面了。

在客户端访问

http://mail.wisefund.com/extman 就可以看见Extman后台管理登录界面了

默认管理员账户:root@extmail.org

默认密码:extmail*123*

 

clip_image018

clip_image020

 

 

 

 

 

 

clip_image034

 

设置邮件系统的图形化日志信息

[root@localhost ~]# ln -f /usr/local/apache2/htdocs/extman/addon/mailgraph_ext/mailgraph-init /usr/sbin/

[root@localhost ~]# ln -sf /usr/local/apache2/htdocs/extman/addon/mailgraph_ext/qmonitor-init /usr/sbin/

[root@localhost ~]# cp -a /usr/local/apache2/htdocs/extman/addon/mailgraph_ext /usr/local/

[root@localhost ~]# mailgraph-init start

[root@localhost ~]# qmonitor-init start

[root@localhost ~]# echo "/usr/sbin/mailgraph-init start" &gt;&gt;/etc/rc.d/rc.local

[root@localhost ~]# echo "/usr/sbin/qmonitor-init start" &gt;&gt;/etc/rc.d/rc.local

clip_image038

垃圾邮件过滤

根据客户端的主机名/地址过滤邮件

首先在/etc/postfix/main.cf使用smtpd_client_restrictions配置参数,设置限制条件:

[root@localhost ~]# vim /etc/postfix/main.cf

655 smtpd_client_restrictions = check_client_access hash:/etc/postfix/access

设置客户端地址访问控制列表:

[root@localhost ~]# vim /etc/postfix/access

407 192.168.2 REJECT

408 192.168.2.1 OK

409 a.org REJECT

将access文件转换为hash数据库文件:

[root@localhost ~]# postmap /etc/postfix/access

[root@localhost ~]# postfix stop

[root@localhost ~]# postfix start

进行测试:

clip_image040

经测试来自b.org的被过滤掉:

clip_image042

clip_image044

可以收到来自a.org的邮件:

clip_image046

根据客户机HELO 信息中的主机名地址过滤邮件

[root@localhost ~]# vim /etc/postfix/main.cf

要求必须使用helo命令:

656 smtpd_helo_required = yes

拒绝使用无效主机名的主机:

657 smtpd_helo_restrictions = reject_invalid_hostname

[root@localhost ~]# postfix reload

clip_image048

根据发件人的地址过滤邮件

[root@localhost ~]# vim /etc/postfix/main.cf

656 smtpd_helo_required = yes

657 smtpd_helo_restrictions = mail.wisefund.com

指定mysql类型的查询表文件和别名文件:

658 smtpd_sender_login_maps =

659 mysql:/etc/postfix/mysql_virtual_sender_maps.cf,

660 mysql:/etc/postfix/mysql_virtual_alias_maps.cf

661 smtpd_sender_restrictions =

662 permit_mynetworks,

发件人与登录用户不匹配时拒绝:

663 reject_sender_login_mismatch,

发件人地址不属于合法FQDN时拒绝:

664 reject_non_fqdn_sender,

发件人地址未知或不存在时拒绝:

665 reject_unknown_sender_domain,

用于指向含有邮件地址域名地址的查询表,即rcpt to: 提供的信息 ---实际上是收件人地址:

666 check_sender_access hash:/etc/postfix/sender_access

667 inet_interfaces = 192.168.2.1,127.0.0.1

[root@localhost ~]# vim /etc/postfix/sender_access

user1@ REJECT

user2@ REJECT

[root@localhost postfix]# postfix reload

[root@localhost postfix]# postmap /etc/postfix/sender_access

clip_image050

根据收件人的地址过滤邮件

首先在/etc/postfix/main.cf配置收件人的地址过滤邮件

655 smtpd_client_restrictions = check_client_access hash:/etc/postfix/access

656 smtpd_helo_required = yes

657 smtpd_helo_restrictions = mail.wisefund.com

658 smtpd_sender_login_maps =

659 mysql:/etc/postfix/mysql_virtual_sender_maps.cf,

660 mysql:/etc/postfix/mysql_virtual_alias_maps.cf

661 smtpd_sender_restrictions =

662 permit_mynetworks,

663 reject_sender_login_mismatch,

664 reject_non_fqdn_sender,

665 reject_unknown_sender_domain,

666 check_sender_access hash:/etc/postfix/sender_access

允许本邮件系统发出的邮件:

667 smtpd_recipient_restrictions =

668 permit_mynetworks,

允许通过sasl认证的用户作为发件人:

669 permit_sasl_authenticated,

收件人地址域不包括在postfix授权网络内时拒绝:

670 reject_unauth_destination,

收件人地址域不属于合法FQDN时拒绝:

671 reject_non_fqdn_recipient,

收件人地址域或不存在时拒绝:

672 reject_unknown_recipient_domain

[root@localhost ~]# postfix reload

基于邮件内容的过滤

安装并配置MailScanner 扫描调度工具

1) 安装MailScanner 扫描调度工具

[root@localhost ~]# tar -zxvf MailScanner-4.84.3-1.rpm.tar.gz

[root@localhost ~]# cd MailScanner-4.84.3-1

[root@localhost MailScanner-4.84.3-1]# ./install.sh

2) 修改配置文件MailScanner

[root@localhost MailScanner-4.84.3-1]# vim /etc/MailScanner/MailScanner.conf

131 Run As User = postfix

135 Run As Group = postfix

165 Incoming Queue Dir = /var/spool/postfix/hold

169 Outgoing Queue Dir = /var/spool/postfix/incoming

196 MTA = postfix

2231 Required SpamAssassin Score = 7

2499 High Scoring Spam Actions = delete forward spam@extmail.org

3) 配置Postfix 支持调用MailScanner

[root@localhost MailScanner-4.84.3-1]# vim /etc/postfix/main.cf

517 header_checks = regexp:/etc/postfix/header_checks

[root@localhost MailScanner-4.84.3-1]# vim /etc/postfix/header_checks

420 /^Received:/HOLD

4) 调整邮件过滤队列的目录属主、属组,并启动MailScanner 服务程序

[root@localhost ~]# chown -R postfix.postfix /var/spool/MailScanner/incoming/

[root@localhost ~]# chown -R postfix.postfix /var/spool/MailScanner/quarantine/

[root@localhost ~]# service MailScanner start

[root@localhost ~]# chkconfig --level 35 MailScanner on

安装并配置SpamAssassin 垃圾邮件过滤器

1) 安装并配置SpamAssassin 垃圾邮件过滤器

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/

[root@localhost ~]# cd /mnt/cdrom/Server/

[root@localhost Server]# yum install -y spamassassin

2) 修改配置文件local.cf

(位于“/etc/mail/spamassassin/local.cf”,一般不需要进行任何修改,保持默认设置即可)

3) 启动SpamAssassin 服务

[root@localhost Server]# service spamassassin start

[root@localhost Server]# chkconfig --level 35 spamassassin on

安装并配置F-Port 病毒查杀软件

1) 安装F-Port 软件包安装过程中出现提示是按回车键接受默认设置:

[root@localhost ~]# tar -zxvf fp-Linux-i686-ws.tar.gz -C /opt/

[root@localhost ~]# cd /opt/f-prot/

[root@localhost f-prot]# ./install-f-prot.pl

2) 升级F-Port 病毒库(服务器要能够访问Internet 互联网):

[root@localhost f-prot]# /opt/f-prot/fpupdate

[root@localhost f-prot]# crontab -e

00 8 * * * /opt/f-prot/fpupdate

[root@localhost f-prot]# service crond restart

[root@localhost f-prot]# chkconfig --level 35 crond on

Extmail登录

邮件用户登录界面首页

clip_image086

偏好设置

这里可以设置个人的信息包括姓名、密码及密码问题等

clip_image088

其他选项卡同其他的邮件服务器一样。

注意:一直登陆不上extman,提示校验码不对,是因为系统时间和客户端时间不对

 

安装过程出现问题解决:

apache启动出错:

[root@localhost ~]# /usr/local/apache2/bin/apachectl restart

image

[root@localhost ~]# fuser -k -n tcp 80

[root@localhost ~]# /usr/local/apache2/bin/apachectl start

postfix不支持mysql的解决办法:

postconf –m

btree

cidr

environ

hash

nis

proxy

regexp

static

unix

所出错误:

[root@localhost ~]# telnet localhost 25

Trying 127.0.0.1...

Connected to localhost.localdomain (127.0.0.1).

Escape character is '^]'.

[root@localhost ~]# tail /var/log/maillog

Apr 11 09:08:14 localhost postfix/smtpd[27864]: fatal: unsupported dictionary type: mysql

Apr 11 09:08:15 localhost postfix/master[27770]: warning: process /usr/libexec/postfix/smtpd pid 27864 exit status 1

Apr 11 09:08:15 localhost postfix/master[27770]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

Apr 11 09:08:28 localhost postfix[27879]: fatal: usage: postfix [-c config_dir] [-Dv] command

Apr 11 09:09:19 localhost postfix/smtpd[27898]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled

解决办法:

[root@localhost postfix-2.6.2]# cd /usr/local/src/

[root@localhost postfix-2.6.2]# cd postfix-2.6.2

[root@localhost postfix-2.6.2]# make clean

[root@localhost postfix-2.6.2]# cd ..

[root@localhost src]# rm -rf postfix-2.6.2

[root@localhost ]# tar -zxvf postfix-2.6.2.tar.gz -C /usr/local/src/

[root@localhost ]# cd /usr/local/src/

[root@localhost src]# cd postfix-2.6.2

[root@localhost postfix-2.6.2]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'

[root@localhost postfix-2.6.2]# make

[root@localhost postfix-2.6.2]# make install

[root@localhost postfix-2.6.2]# newaliases

[root@localhost postfix-2.6.2]# postconf -m

btree

cidr

environ

hash

mysql

nis

proxy

regexp

static

unix