Linux下部署企业级邮件服务器(postfix + dovecot + extmail)

清泛编译
首先通过一幅图看看整个解决方案的原理: 

当用户通过extmail登陆时,首先extmail先去通过mysql进行虚拟用户认证,当认证通过时,postfix通过Cyrus-SASL这个函数库,这个认证框架,结合Courier-authlib对发信人进行认证,通过检索Mysql数据库中的数据来进行认证,以此来判定收件人所在的域是否为自己所负责的域,并且判断是否为其中继邮件。

需求:为公司建立邮件服务器,公司全部员工使用统一的域名,内网IP为:192.168.0.115

操作系统:RHEL5
所用软件列表:
mysql-5.5.20
postfix-2.9.1
courier-authlib-0.62.4.tar.bz2
extmail-1.2.tar.gz
extman-1.1.tar.gz
Unix-Syslog-1.1.tar.gz
perl-GD-2.35-1.el5.rf.i386.rpm 
rrdtool-1.2.23
Time-HiRes-1.9725.tar.gz
File-Tail-0.99.3.tar.gz


一、环境配置
1、安装一下过程中所依赖的一些rpm包
yum install -y tcl-devel libart_lgpl-devel libtool-ltdl-devel

 

2、关闭sendmail,并取消其开机启动
service sendmail stop
chkconfig sendmail off


3、配置编译环境,安装开发包组
yum groupinstall -y "Development Tools" "Development Libraries"

二、启动所需服务
1、安装启动mysql
mysql的安装具体过程这里不在详述,我的博客中其他文章中多次写出过。不熟悉的朋友可以参考

2、启动saslauthd服务,并设为开机启动

service saslauthd start
chkconfig saslauthd on

三、编译安装postfix
说明:RHEL5中的postfix rpm包不支持基于mysql认证功能,所以这里要源码编译安装postfix
从配置简单方面考虑,我们根据postfix的默认配置条件进行新建用户等,以免漏掉某些修改,导致的一些麻烦

1、建立postfix用户,并且指定UID,GID为2525,组postdrop

groupadd -g 2525 postfix
useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
groupadd -g 2526 postdrop
useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop

2、解压编译安装postfix
tar zxvf postfix-2.9.1.tar.gz
cd postfix-2.9.1
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  -DUSE_TLS ' 'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2  -lssl -lcrypto'
make
make install

说明:在执行make makefiles命令时根据个人环境正确指定mysql的头文件以及库文件,笔者mysql安装在/usr/local/mysql

按照以下提示做相应的选择,不做修改表示使用[]中的默认值
先将mysql的lib目录加入 /etc/ld.so.conf,然后执行ldconfig命令使其生效,否则填完以下install配置后,会出现错误"bin/postconf: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory"。
若postfix报错postfix: fatal: parameter inet_interfaces: no local interface found for ::1 
则 vi /etc/postfix/main.cf修改配置:

inet_interfaces = all
install_root: [/] 
tempdir: [/root/postfix-2.9.1] /tmp/postfix
config_directory: [/etc/postfix] 
command_directory: [/usr/sbin]
daemon_directory: [/usr/libexec/postfix] 
data_directory: [/var/lib/postfix]
html_directory: [no] 
mail_owner: [postfix]
mailq_path: [/usr/bin/mailq]
manpage_directory: [/usr/local/man]
newaliases_path: [/usr/bin/newaliases]
queue_directory: [/var/spool/postfix] 
readme_directory: [no] 
sendmail_path: [/usr/sbin/sendmail] 
setgid_group: [postdrop] 

3、为postfix提供Syv服务/etc/rc.d/init.d/postfix脚本
脚本朋友们可以从附件中下载


4、对postfix进行基本配置,测试启动发信
编辑/etc/postfix/main.cf

myhostname = mail.huatuo.com     #指定运行postfix邮件系统的主机的主机名
myorigin = huatuo.com            #指明发件人所在的域名
mydomain = huatuo.com            #指定域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain        #指定对哪些域设置开放式中继
mynetworks = 192.168.0.0/24, 127.0.0.0/8        #指定你所在的网络的网络地址,postfix系统根据其值来区别用户是远程的还是本地的,如果是本地网络用户则允许其访问

注意:
1、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;
2、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;
3、每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动postfix;
4、如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每个行前多置一个空格即可;postfix会把第一个字符为空格或tab的文本行视为上一行的延续;


5、启动postfix,连接发信

 

四、为postfix开启基于cyrus-sasl认证功能
1、检查postfix是否支持cyrus-sasl认证
postconf -a

2、配置postfix的主配置文件
vim /etc/postfix/main.cf
在最后添加以下内容

############################CYRUS-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
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!


说明:
broken_sasl_auth_clients = yes:开启基于基于sasl认证客户端
smtpd_recipient_restrictions:根据收件人地址进行过滤控制
    permit_mynetworks:如果主机是mynetworks中定义的则允许
    permit_sasl_authenticated:允许通过sasl认证的主机
    reject_invalid_hostname:如果SMTP helo/ehlo命令中的主机名语法无效则拒绝
    reject_non_fqdn_hostname:如果主机地址不是正规的FQDN格式则拒绝
    reject_unknown_sender_domain:如果DNS无法解析发件人则拒绝
    reject_unknown_recipient_domain:如果DNS无法解析收件人则拒绝
    reject_non_fqdn_sender:如果发件人的地址不是正规的FQDN格式则拒绝
    reject_non_fqdn_recipient:如果收件人的收件地址不是正规的FQDN格式则拒绝
    reject_unauth_pipelining:拒绝验证未通过的
    reject_unauth_destination:如果目标地址在relay_domains或my_destinations中则拒绝

smtpd_sasl_auth_enable = yes:开启smtp基于sasl认证
smtpd_sasl_local_domain = $myhostname:sasl认证时$myhostname为本地域
smtpd_sasl_security_options = noanonymous:sasl认证不允许匿名用户
smtpd_sasl_application_name = smtpd:sasl应用程序名是smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Availab
le!smtpdbanner信息
朋友们根据个人需要对配置进行修改

vim /usr/lib/sasl2/smtpd.conf
添加如下内容:

pwcheck_method: saslauthd
mech_list: PLAIN LOGIN


重新载入postfix

3、验证此刻postfix是否支持认证

五、安装courier-authlib
1、courier-authlib
courier-authlib是Courier组件中的认证库,它是courier组件中一个独立的子项目,用于为Courier的其它组件提供认证服务。其认证功能通常包括验正登录时的帐号和密码、获取一个帐号相关的家目录或邮件目录等信息、改变帐号的密码等。而其认证的实现方式也包括基于PAM通过/etc/passwd和/etc/shadow进行认证,基于GDBM或DB进行认证,基于LDAP/MySQL/PostgreSQL进行认证等。因此,courier-authlib也常用来与courier之外的其它邮件组件(如postfix)整合为其提供认证服务。


2、安装courier-authlib

tar jxvf courier-authlib-0.62.4.tar.bz2
cd courier-authlib-0.62.4
./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --without-authpam --without-authshadow --without-authvchkpw --without-authpgsql --with-authmysql --with-mysql-libs=/usr/local/mysql/lib --with-mysql-includes=/usr/local/mysql/include --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-ltdl-lib=/usr/lib --with-ltdl-include=/usr/include

说明:此处请根据个人环境修改mysql的头文件以及库文件的路径
make
make install


3、提供修改配置文件
cp /etc/authdaemonrc.dist  /etc/authdaemonrc
cp /etc/authmysqlrc.dist  /etc/authmysqlrc

修改/etc/authdaemonrc 文件

authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10

修改/etc/authmysqlrc

MYSQL_SERVER            mysql.example.com
MYSQL_USERNAME          admin
MYSQL_PASSWORD          admin
MYSQL_PORT              0
MYSQL_DATABASE          mysql
MYSQL_USER_TABLE        passwd
MYSQL_CRYPT_PWFIELD     crypt
MYSQL_UID_FIELD         uid
MYSQL_GID_FIELD         gid
MYSQL_LOGIN_FIELD       id
MYSQL_HOME_FIELD        home
MYSQL_NAME_FIELD        name
# MYSQL_MAILDIR_FIELD   maildir
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_PORT              3306
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
MYSQL_UID_FIELD         2525
MYSQL_GID_FIELD         2525
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     concat('/var/mailbox/',maildir)

4、提供Sysv风格的服务脚本
在courier-authlib的源码解压目录下将courier-authlib.sysvinit复制到/etc/rc.d/init.d下

cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
chmod a+x /etc/rc.d/init.d/courier-authlib

使用functions文件中的success failure函数对该脚本进行修改,修改过的脚本大家可以在附件中下载

echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
ldconfig
chkconfig --add courier-authlib
chkconfig courier-authlib on


新建虚拟用户邮箱所在目录

mkdir –pv /var/mailbox
chown –R postfix /var/mailbox


重新配置SMTP认证,编辑/usr/lib/sasl2/smtpd.conf修改内容为

pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket


六、让postfix支持虚拟域和虚拟用户

(虚拟域:可以使用实际上不存在或不可访问的域名作为“@”域地址;虚拟用户:此处的虚拟用户指的是不需要服务器真正存在的用户,只需要去配置的数据库中验证。)
1、编辑/etc/postfix/main.cf,添加如下内容:
########################Virtual Mailbox Settings########################
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:2525
virtual_gid_maps = static:2525
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
##########################QUOTA Settings########################
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/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 Tidy your mailbox and try again later.
virtual_overquota_bounce = yes

2、取消中心域(添加上述配置前,是使用本地的用户名密码验证,需要mydestination配置。添加虚拟用户配置后,一定要去掉mydestination,否则出错!!)

启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也可以把mydestionation的值改为你自己需要的。

重启postfix
service postfix restart

七、安装配置dovecot
yum install -y dovecot
vim /etc/dovecot.conf

将对应部分内容修改为
auth default {
    mechanisms = plain
    passdb sql {
        args = /etc/dovecot-mysql.conf
    }
    userdb sql {
        args = /etc/dovecot-mysql.conf
    }


编辑/etc/dovecot-mysql添加如下内容

driver = mysql
connect = host=/tmp/mysql.sock 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'

启动dovecot
service dovecot start

八、安装extman
1、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库
由于extman版本较早,其sql脚本是针对mysql-5.0的,对于现在mysql-5.5的语法稍有不适用
因此编辑extmaul.sql 将“TYPE=MyISAM”全部改为“ENGINE=MyISAM”,修改之后使用该脚本建立数据库

mysql -uroot -p < extmail.sql 
mysql -uroot -p < init.sql
cp mysql_virtual_* /etc/postfix/


2、创建访问extmail数据库的用户并且赋予权限
mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)


3、安装配置apache
yum install httpd -y
vim /etc/httpd/conf/httpd.conf

注释掉中心主机,启用虚拟主机
添加以下内容:

<VirtualHost *:80>
        ServerName mail.huatuo.com
        DocumentRoot /var/www/extmail/html/
        ScriptAlias /extmail/cgi /var/www/extmail/cgi
        Alias /extmail /var/www/extmail/html
        SuexecUserGroup postfix postfix
        ScriptAlias /extman/cgi /var/www/extman/cgi
        Alias /extman /var/www/extman/html
</VirtualHost>


4、提供extman网页并配置
将解压出来的extman移动到/var/www下

mv extman-1.1 /var/www/extman
cp /var/www/extman/webman.cf.default /var/www/extman/webman.cf
vim /var/www/extman/webman.cf

 

部分修改选项的说明:
SYS_CONFIG = /var/www/extman/
SYS_LANGDIR = /var/www/extman/lang
SYS_TEMPLDIR = /var/www/extman/html

SYS_MAILDIR_BASE = /home/domains
此处即为您在前文所设置的用户邮件的存放目录,可改作:
SYS_MAILDIR_BASE = /var/mailbox

SYS_DEFAULT_UID = 1000
SYS_DEFAULT_GID = 1000
此两处后面设定的ID号需更改为前而创建的postfix用户和postfix组的id号,本文使用的是2525,因此,上述两项需要修改为:
SYS_DEFAULT_UID = 2525
SYS_DEFAULT_GID = 2525

SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
修改为:
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail

SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
修改为:
SYS_MYSQL_SOCKET = /tmp/mysql.sock

而后修改cgi目录的属主:
chown -R postfix.postfix /var/www/extman/cgi/

在apache的主配置文件中Extmail的虚拟主机部分,添加如下两行:
ScriptAlias /extman/cgi /var/www/extman/cgi
Alias /extman /var/www/extman/html


创建其运行时所需的临时目录,并修改其相应的权限:

mkdir  -pv  /tmp/extman
chown postfix.postfix  /tmp/extman


5、提供extmail网页并配置
将解压出来的extman移动到/var/www下

tar xvf extmail-1.2.tar.gz 
mv extmail-1.2 /var/www/extmail
cd /var/www/extmail/
cp webmail.cf.default webmail.cf
vim /var/www/extmail/webmail.cf

  部分修改说明:
SYS_CONFIG = /var/www/extmail/
SYS_LANGDIR = /var/www/extmail/lang
SYS_TEMPLDIR = /var/www/extmail/html
SYS_G_ABOOK_FILE_PATH = /var/www/extmail/globabook.cf

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_SOCKET = /var/lib/mysql/mysql.sock
修改为:
SYS_MYSQL_SOCKET = /tmp/mysql.sock

SYS_MYSQL_HOST = localhost
指明数据库服务器主机名,这里默认即可

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

6、解决依赖关系
extmail将会用到perl的Unix::syslogd功能
tar zxvf Unix-Syslog-1.1.tar.gz
cd Unix-Syslog-1.1
perl Makefile.PL
make
make install


正常使用校验码
安装perl-GD模块可以解决
yum install gd-devel
wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.53.tar.gz
tar -zxvf GD-2.53.tar.gz
cd GD-2.53
perl Makefile.PL
make
make install 


安装连接mysql的驱动模块
yum install -y perl-DBD-MySQL

安装perl-CGI模块,否则启动浏览器页面会报错:Can't locate CGI.pm in @INC (@INC contains:...
yum install perl-CGI

启动apache
service httpd start

九、验证
在浏览器中输入192.168.0.105

 

十、配置Mailgraph_ext,使用Extman的图形日志:
接下来安装图形日志的运行所需要的软件包Time::HiRes、File::Tail和rrdtool
首先在http://search.cpan.org
搜索:Time::HiRes和File::Tail:并下载
http://oss.oetiker.ch/rrdtool/pub/?M=D 下载rrdtool-1.2.23.tar.gz


1、安装Time::HiRes
tar zxvf Time-HiRes-1.9707.tar.gz 
cd Time-HiRes-1.9707
perl Makefile.PL 
make
make test
make install


2、安装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


3、安装rrdtool-1.2.23
yum install -y libpng-devel freetype
tar zxvf rrdtool-1.2.23.tar.gz 
cd rrdtool-1.2.23
./configure --prefix=/usr/local/rrdtool
make
make install

cp -r /var/www/extsuite/extman/addon/mailgraph_ext   /usr/local  
/usr/local/mailgraph_ext/mailgraph-init   start


启动报错:

/usr/local/mailgraph_ext/mailgraph-init start
Starting mail statistics grapher: mailgraph_ext
Can't locate RRDs.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/mailgraph_ext/mailgraph_ext.pl line 292.
BEGIN failed--compilation aborted at /usr/local/mailgraph_ext/mailgraph_ext.pl line 292.
Starting queue statistics grapher: qmonitor
Can't locate RRDs.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/mailgraph_ext/qmonitor.pl line 8.
BEGIN failed--compilation aborted at /usr/local/mailgraph_ext/qmonitor.pl line 8.

解决方法:

ln -sv /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/RRDs.pm /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/

ln -sv /usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/RRDs/RRDs.so /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/


(如果碰到少别的模块都可以用查找链接这种方法解决,找不到就是没安装,一个是模块,一个是库)
/usr/local/mailgraph_ext/qmonitor-init   start //启动ok

/var/www/extman/daemon/cmdserver -d  //打开系统信息

加入开机启动脚本中,达到开机启动的目的
echo "/usr/local/mailgraph_ext/mailgraph-init start" >> /etc/rc.local
echo “/var/www/extman/daemon/cmdserver -d” >> /etc/rc.d/rc.local 

查看系统信息

打开图形日志:

可以看出图形日志中已经有图形了。至此
Postfix+courier-authlib+dovecot+mysql+extmail构建企业邮件应用已经完成。

剩下只需要为服务器的公网IP添加为MX记录就OK了。



常见问题及解决方法:
1、
May 12 16:10:29 mail postfix/smtpd[3861]: connect from localhost[127.0.0.1]
May 12 16:10:29 mail postfix/smtpd[3861]: warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms
May 12 16:10:29 mail postfix/smtpd[3861]: fatal: no SASL authentication mechanisms
May 12 16:10:30 mail postfix/master[2544]: warning: process /usr/libexec/postfix/smtpd pid 3861 exit status 1
May 12 16:10:30 mail postfix/master[2544]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling
进入源码目录重新make install安装postfix,即可解决。不行的话,重新安装saslauthd,删除(略)
cyrus-sasl-2.1.22.tar.gz
./configure --disable-anon --enable-login --enable-plain --enable-sql --with-mysql=/opt/tfdata/mysql --with-mysql-includes=/opt/tfdata/mysql/include \ --with-mysql-libs=/opt/tfdata/mysql/lib --enable-sample --with-plugindir=/usr/local/lib/sasl2  
若出现编译cyrus-sasl错误:
digestmd5.c:3125: warning: pointer targets in passing argument 3 of 'text->cipher_init' differ in signedness digestmd5.c:3125: note: expected 'unsigned char *' but argument is of type 'char *' digestmd5.c: In function 'digestmd5_client_mech_step1': digestmd5.c:3712: warning: pointer targets in passing argument 2 of '_plug_strdup' differ in signedness plugin_common.h:147: note: expected 'const char *' but argument is of type 'unsigned char *' digestmd5.c:3715: warning: pointer targets in passing argument 2 of '_plug_strdup' differ in signedness plugin_common.h:147: note: expected 'const char *' but argument is of type 'unsigned char *' digestmd5.c:3683: warning: unused parameter 'serverin' digestmd5.c:3684: warning: unused parameter 'serverinlen' digestmd5.c: In function 'digestmd5_client_mech_step3': digestmd5.c:3818: warning: unused parameter 'prompt_need' digestmd5.c:3819: warning: unused parameter 'clientout' digestmd5.c:3820: warning: unused parameter 'clientoutlen' digestmd5.c: In function 'digestmd5_client_mech_step': digestmd5.c:3980: warning: pointer targets in assignment differ in signedness digestmd5.c:4017:15: error: #elif with no expression make[2]: *** [digestmd5.lo] 错误 1 make[2]:正在离开目录 `/root/linuxsoft/cyrus-sasl-2.1.21/plugins' make[1]: *** [all-recursive] 错误 1 make[1]:正在离开目录 `/root/linuxsoft/cyrus-sasl-2.1.21' make: *** [all] 错误 2
解决方法:sed -i.bak 's/#elif WITH_DES/#elif defined(WITH_DES)/' plugins/digestmd5.c

启动saslauthd并测试
   # /usr/local/sbin/saslauthd -a shadow pam
开机自动启动
   # echo "/usr/local/sbin/saslauthd -a shadow pam" >> /etc/rc.local # vi /usr/local/lib/sasl2/smtpd.conf pwcheck_method: authdaemond log_level:3 mech_list: PLAIN LOGIN authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket

2、日志太多,删除/var/log/message,/var/log/maillog后,系统不再记录log了解决方法重启log服务:service rsyslog restart。没有rsyslog的话yum install rsyslog。

3、问题:
DBD::mysql::db do failed: INSERT command denied to user 'extmail'@'localhost' for table 'domain' at /var/www/extsuite/extman/libs/Ext/Mgr/MySQL.pm line 359. 
解决:执行以下SQL
grant all privileges on *.* to 'extmail'@'localhost' identified by 'extmail' with grant option;
flush privileges;


4、QQ邮箱邮件乱码问题:

查看邮件编码,发现这封邮件的编码是:gb18030.手动把编码改成:gb2312邮件就可以正常显示。

关于GB18030 :由thunderbird或某些客户端软件发出的中文邮件编码是GB18030,部分内容甚至全部乱码。经过仔细检查发现是Perl 目前版本(5.8.8或以下)缺少了GB18030码表,因此增加了Encode::HanExtra码表模块的支持,解决了此问题。 

解决方法
[root@mail ~]# wget -c http://search.cpan.org/CPAN/authors/id/A/AU/AUDREYT/Encode-HanExtra-0.23.tar.gz
--09:40:49--  http://search.cpan.org/CPAN/authors/id/A/AU/AUDREYT/Encode-HanExtra-0.23.tar.gz
Resolving search.cpan.org... 199.15.176.161
Connecting to search.cpan.org|199.15.176.161|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.cpan.org/authors/id/A/AU/AUDREYT/Encode-HanExtra-0.23.tar.gz [following]
--09:40:50--  http://www.cpan.org/authors/id/A/AU/AUDREYT/Encode-HanExtra-0.23.tar.gz
Resolving www.cpan.org... 207.171.7.177, 212.117.177.118, 2620:101:d000:8::140:1, ...
Connecting to www.cpan.org|207.171.7.177|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1566682 (1.5M) [application/octet-stream]
--09:40:53--  (try: 2)  http://www.cpan.org/authors/id/A/AU/AUDREYT/Encode-HanExtra-0.23.tar.gz
Reusing existing connection to www.cpan.org:80.
HTTP request sent, awaiting response... 200 OK
Length: 1566682 (1.5M) [application/octet-stream]
Saving to: `Encode-HanExtra-0.23.tar.gz'

100%[======================================================================================================>] 1,566,682   33.7K/s   in 52s    

09:41:45 (29.6 KB/s) - `Encode-HanExtra-0.23.tar.gz' saved [1566682/1566682]

[root@mail ~]# chmod 755 Encode-HanExtra-0.23.tar.gz
[root@mail ~]# gunzip Encode-HanExtra-0.23.tar.gz
[root@mail ~]# tar xvf Encode-HanExtra-0.23.tar 
Encode-HanExtra-0.23/
Encode-HanExtra-0.23/Changes
Encode-HanExtra-0.23/inc/
Encode-HanExtra-0.23/inc/Module/
Encode-HanExtra-0.23/inc/Module/Install/
Encode-HanExtra-0.23/inc/Module/Install/Base.pm
......
[root@mail Encode-HanExtra-0.23]# perl Makefile.PL 
enc2xs is /usr/bin/enc2xs
encode.h is at /usr/lib/perl5/5.8.8/Encode
Checking if your kit is complete...
Looks good
Writing Makefile for Encode::HanExtra
[root@mail Encode-HanExtra-0.23]# make install
cp lib/Encode/TW/Unisys/SOSI1.pm blib/lib/Encode/TW/Unisys/SOSI1.pm
cp lib/Encode/HanExtra.pm blib/lib/Encode/HanExtra.pm
cp lib/Encode/TW/Unisys/SOSI2.pm blib/lib/Encode/TW/Unisys/SOSI2.pm
/usr/bin/perl "-Iinc"  /usr/bin/enc2xs -"Q" -o Big5_t.c -f Big5_t.fnm
Reading big5-1984 (big5-1984)
Reading big5-2003 (big5-2003)
......
......
Installing /usr/share/man/man3/Encode::TW::Unisys::SOSI1.3pm
Installing /usr/share/man/man3/Encode::HanExtra.3pm
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Encode/HanExtra/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
make install完成之后,不需要重启服务,刷新页面即可看到中文显示正常浏览。 

5、dovecot: pop3-login: Aborted login (auth failed, 1 attempts)
conf.d/10-auth.conf:
#!include auth-system.conf.ext  改为
#!include auth-sql.conf.ext


6、Error: dovecot: auth: Fatal: Unknown database driver 'mysql'
yum install dovecot-mysql;

邮件 服务器 postfix dovecot extmail

分享到:
评论加载中,请稍后...
创APP如搭积木 - 创意无限,梦想即时!
回到顶部