基于mysql+cryus-courier-authlib+dovecot+postfxi邮件服务器的部署


博文结构

一.实验环境准备

二.postfix安装与配置

三.配置虚拟用户支持的SMTP认证

四.安装配置dovecot

五.部署邮件使用与管理界面


 邮件服务是互联网中常见的服务之一,企业对于有一人功能强大,性能稳定的邮件服务非常重要。本节就对linux下的基于postfix、dovecot、mysql、courier-authlib的邮件服务器的构建作一个详细说明。后面将列出常见问题,仅作为参考。


电子邮件传输过程流程图

MTA: 一般被称为邮件服务器软件,负责接收客户端软件发送的邮件,并将邮件传输给其他的 MTA 程序,是电子邮件系统中的核心部分

―― 例如Postfix软件

MUA:一般被称为邮件客户端软件,负责为用户提供发送、接收和管理电子邮件的界面

―― 例如OutlookFoxmail

MDA:负责在服务器中将邮件分发到用户的邮箱目录,它并不直接面向邮件用户,而是在后台默默的工作。有时候MDA的功能可以直接集成在MTA软件中。

POP3 协议用于收取电子邮件,通常需要将邮件内容全部下载后才能进行阅读,110端口。
IMAP4 协议用于收取、管理电子邮件,可以在下载邮件之前先查看对应的邮件头,以确定需要下载还是删除等操作,更适合用于电子邮件的远程管理,143端口


                                                    虚拟用户的邮件服务器的系统架构图

一.实验环境准备

1.软件包获取

1.http://www.dovecot.org/releases/2.2/dovecot-2.2.2.tar.gz

dovecot-2.2.2.tar.gz    


2.http://www.extmail.org/download

extmail-1.1.1.tar.gz                    

extman-1.0.1.tar.gz  

mysql-5.6.11.tar.gz


3.ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.10.0.tar.gz


4.http://www.courier-mta.org/download.php#authlib

courier-authlib-0.65.0.20130314.tar.bz2


5.http://search.cpan.org/

File-Tail-0.99.3.tar.gz

DBD-mysql-4.023.tar.gz                  

GD-2.49.tar.gz

DBI-1.627.tar.gz

Unix-Syslog-1.1.tar.gz

注:在这里我下载的软件大部分是最新的软件包,如dovecot,它和以前的包配置有点不同。


2.基础环境描述

本实验的域为longining.com,在named中已经加了两个域名为mail.longining.com,man.longining.com.

安装基础包

[root@Nodes01 mail]# yum install -y cyrus-sasl cyrus-sasl-devel mysql-server mysql-devel httpd httpd-devel


二.postfix安装与配置

postfix是一款非常不错蝗邮件服务软件,具有安全,快速易于管理的特点。


1.创建用户及组

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

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

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

2.解压并安装

[root@Nodes01 mail]# tar -zxvf postfix-2.10.0.tar.gz

[root@mail postfix-2.4.6]# make makefiles \

> 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql/ \

> -DUSE_SASL_AUTH \

> -DUSE_CYRUS_SASL -I/usr/include/sasl' \

> 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient  -lz  -lm  \

> -L/usr/lib/sasl2  -lsasl2 '

[root@mail postfix-2.4.6]# make && make install


3.验证是否支持cyrus、dovecot、mysql相关模块

[root@Nodes01 ~]# postconf -a

cyrus

dovecot

[root@Nodes01 ~]# postconf -m | grep mysql

mysql

4.简化配置文件并加入基于虚拟用户的配置选项

简化配置文件

[root@Nodes01 ~]# cd /etc/postfix/

[root@Nodes01 postfix]# postconf -n > main2.cf

[root@Nodes01 postfix]# mv main.cf main.cfbk

[root@Nodes01 postfix]# mv main2cf main.cf

postfix的配置文件main.cf选项如下


command_directory = /usr/sbin

config_directory = /etc/postfix

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix

debug_peer_level = 2

debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5

html_directory = no

inet_protocols = ipv4

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

sample_directory = /etc/postfix

sendmail_path = /usr/sbin/sendmail

setgid_group = postdrop

unknown_local_recipient_reject_code = 550

#Base adding

inet_interfaces=all

myhostname=mail.longining.com

mydomain=longining.com

myorigin=$mydomain

#mydestination=$mydomain,$myhostname    配置虚拟用户时需要将此项注释

home_mailbox=Maildir/

alias_maps = hash:/etc/aliases

################################基于smtp auth的配置选项##############

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

mynetworks = 127.0.0.0/8,192.168.4.0/24

smtpd_sasl_local_domain=$mydomain       使用全域名登录查询

smtpd_recipient_restrictions =permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination




#############################adding virtual基于虚拟用户的配置选项##########

virtual_mailbox_base=/mailbox

virtual_alias_maps=mysql:/etc/postfix/mysql_virtual_alias_maps.cf

virtual_mailbox_maps=mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

virtual_mailbox_domains=mysql:/etc/postfix/mysql_virtual_domains_maps.cf

virtual_uid_maps=static:1000

virtual_gid_maps=static:10001


5.创建数据库-mysql

解压exman包,进入docs目录copy虚拟用户配置相关文件到/etc/postfix目录

[root@Nodes01 mail]# tar -zxvf extman-1.0.1.tar.gz -C /var/www/html/

[root@Nodes01 postfix]# cd /var/www/html/extman/docs/

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

导入数据库相关

[root@Nodes01 docs]# mysql -uroot -p < init.sql

[root@Nodes01 docs]# mysql -uroot -p < extmail.sql

注:在导入数据库之前,请将init.sql、extmail.sql文件中相关域改成longining.com


三.配置虚拟用户支持的SMTP认证

1.安装courier-authlib

[root@Nodes01 mail]# tar -jxvf courier-authlib-0.65.0.20130314.tar.bz2

[root@Nodes01 courier-authlib-0.65.0.20130314]# ./configure --    prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-mysql-lib=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql

2.设置主配置文件/usr/local/courier-authlib/etc/authlib/authdaemonrc 的认证方式

authmodulelist="authmysql"

authmodulelistorig="authmysql"

3.设置数据库配置文件/usr/local/courier-authlib/etc/authlib/authmysqlrc

此配置文件千万不能配置错误,否则会导致认证测试失败

MYSQL_SERVER    localhost

MYSQL_USERNAME    extmail

MYSQL_PASSWORD    extmail

MYSQL_SOCKET    /var/lib/mysql/mysql.sock

MYSQL_PORT    3306

MYSQL_OPT        0

MYSQL_DATABASE        extmail

MYSQL_USER_TABLE    mailbox

MYSQL_CRYPT_PWFIELD    password

MYSQL_UID_FIELD    1000

MYSQL_GID_FIELD    1000

MYSQL_LOGIN_FIELD    id

MYSQL_HOME_FIELD    concat('/mailbox/',homedir)

MYSQL_NAME_FIELD    name

MYSQL_MAILDIR_FIELD    concat('/mailbox/',maildir)

4.修改socket目录权限

[root@Nodes01 ~]# vim /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

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

5.添加库文件搜索路径

[root@Nodes01 ~]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf

[root@Nodes01 ~]# echo "/usr/lib/mysql/" >> /etc/ld.so.conf

6.启动courier-authlib

[root@Nodes01 ~]# cp /opt/mail/courier-authlib-0.65.0.20130314/courier-authlib.sysvinit /etc/init.d/courier-authlib

[root@Nodes01 ~]# chmod 755 /etc/init.d/courier-authlib

[root@Nodes01 ~]# /etc/init.d/courier-authlib start

7.进行虚拟用户的测试

在数据库中已经加入了[email protected]测试用户。

获取base64加密的用户名与密码的字符串

[root@Nodes01 ~]# printf "hudaohong" | base64

aHVkYW9ob25n

[root@Nodes01 ~]# printf "123" | base64

MTIz

通过telnet方式连接进行测试

[root@Nodes01 ~]# telnet mail.longining.com 25

Trying 192.168.4.70...

Connected to mail.longining.com.

Escape character is '^]'.

220 mail.longining.com ESMTP Postfix   连接成功

ehlo localhost                         宣告主机地址

250-mail.longining.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-AUTH PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

auth login                             声明认证登录

334 VXNlcm5hbWU6

aHVkYW9ob25n                           加密的用户名字符串

334 UGFzc3dvcmQ6

MTIz                                   加密的密码字符串

235 2.7.0 Authentication successful    表明认证成通过

对应的mail日志记录

Jun  9 18:40:50 Nodes01 postfix/smtpd[10358]: connect from man.longining.com[192.168.4.70]

Jun  9 18:41:36 Nodes01 authdaemond: received auth request, service=smtp, authtype=login

Jun  9 18:41:36 Nodes01 authdaemond: authmysql: trying this module

Jun  9 18:41:36 Nodes01 authdaemond: authmysqllib: connected. Versions: header 50169, client 50169, server 50169

Jun  9 18:41:36 Nodes01 authdaemond: SQL query: SELECT username, password, "", 1000, 1000, concat('/mailbox/', homedir), concat('/mailbox/', maildir), "", name, "" FROM mailbox WHERE username = '[email protected]'

Jun  9 18:41:36 Nodes01 authdaemond: password matches successfully

Jun  9 18:41:36 Nodes01 authdaemond: authmysql: sysusername=<null>, sysuserid=1000, sysgroupid=1000, homedir=/mailbox/longining.com/hudaohong, [email protected], fullname=hudaohong, maildir=/mailbox/longining.com/hudaohong/Maildir/, quota=<null>, options=<null>

Jun  9 18:41:36 Nodes01 authdaemond: Authenticated: sysusername=<null>, sysuserid=1000, sysgroupid=1000, homedir=/mailbox/longining.com/hudaohong, [email protected], fullname=hudaohong, maildir=/mailbox/longining.com/hudaohong/Maildir/, quota=<null>, options=<null>

通过authtest测试

[root@Nodes01 ~]# /usr/local/courier-authlib/sbin/authtest -s lonin [email protected] 123

Authentication succeeded.


Authenticated: [email protected]  (uid 1000, gid 1000)

Home Directory: /mailbox/longining.com/hudaohong

  Maildir: /mailbox/longining.com/hudaohong/Maildir/

Quota: (none)

Encrypted Password: $1$Gy7Fyct7$/MDb8h5G8BuENK/ssGj4D0

Cleartext Password: 123

  Options: (none)

authtest测试对应mail日志

Jun  9 18:44:04 Nodes01 authdaemond: received auth request, service=lonin, authtype=login

Jun  9 18:44:04 Nodes01 authdaemond: authmysql: trying this module

Jun  9 18:44:04 Nodes01 authdaemond: SQL query: SELECT username, password, "", 1000, 1000, concat('/mailbox/', homedir), concat('/mailbox/', maildir), "", name, "" FROM mailbox WHERE username = '[email protected]'

Jun  9 18:44:04 Nodes01 authdaemond: password matches successfully

Jun  9 18:44:04 Nodes01 authdaemond: authmysql: sysusername=<null>, sysuserid=1000, sysgroupid=1000, homedir=/mailbox/longining.com/hudaohong, [email protected], fullname=hudaohong, maildir=/mailbox/longining.com/hudaohong/Maildir/, quota=<null>, options=<null>

Jun  9 18:44:04 Nodes01 authdaemond: Authenticated: sysusername=<null>, sysuserid=1000, sysgroupid=1000, homedir=/mailbox/longining.com/hudaohong, [email protected], fullname=hudaohong, maildir=/mailbox/longining.com/hudaohong/Maildir/, quota=<null>, options=<null>


8.测试的相关问题集

问题1:

Jun  5 20:22:01 Nodes01 postfix/smtpd[5031]: connect from localhost[127.0.0.1]

Jun  5 20:23:04 Nodes01 postfix/smtpd[5031]: warning: SASL authentication failure: cannot connect to Courier authdaemond: Connection refused

Jun  5 20:23:04 Nodes01 postfix/smtpd[5031]: warning: localhost[127.0.0.1]: SASL login authentication failed: generic failure

方法:

[root@Nodes01 ~]# ln -svf /usr/local/courier-authlib/include/* /usr/include/

[root@Nodes01 ~]# ln -s /usr/local/courier-authlib/bin/courierauthconfig /usr/bin/courierauthconfig



问题2:

ehlo localhost

250-mail.longining.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-AUTH PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

auth login

334 VXNlcm5hbWU6

aHVkYW9ob25n

334 UGFzc3dvcmQ6

MTIz

535 5.7.8 Error: authentication failed: authentication failure

日志如下:

Jun  5 21:50:29 Nodes01 authdaemond: authmysql: trying this module

Jun  5 21:50:29 Nodes01 authdaemond: authmysqllib: connected. Versions: header 50169, client 50169, server 50169

Jun  5 21:50:29 Nodes01 authdaemond: SQL query: SELECT username, password, "", 1000, 1000, concat('/mailbox/', homedir), concat('/mailbox/', maildir), "", name, "" FROM mailbox WHERE username = 'hudaohong'

Jun  5 21:50:29 Nodes01 authdaemond: zero rows returned

Jun  5 21:50:29 Nodes01 authdaemond: no password available to compare

Jun  5 21:50:29 Nodes01 authdaemond: authmysql: REJECT - try next module

Jun  5 21:50:29 Nodes01 authdaemond: FAIL, all modules rejected

Jun  5 21:50:29 Nodes01 postfix/smtpd[5449]: warning: localhost[127.0.0.1]: SASL login authentication failed: authentication failure

分析方法:

默认在查询时其条件字段username使用了部分值               hudaohong([email protected])所以匹配不到相关记录,只要在postfix配置文件

main.cf中加入 smtpd_sasl_local_domain=$mydomain.



问题3:


Jun  3 15:46:20 Nodes01 postfix/smtpd[32670]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled

解决方法:

在postfix配置文件main.cf中加入alias_maps = hash:/etc/aliases

四.安装配置dovecot

1.编译安装dovecot

[root@Nodes01 ~]# useradd -M -s /sbin/nologin  dovecot    创建用户

[root@Nodes01 ~]# cd /opt/mail/

[root@Nodes01 mail]# tar -zxvf dovecot-2.2.2.tar.gz

[root@Nodes01 dovecot-2.2.2]# ./configure --sysconfdir=/etc/ --with-mysql

[root@Nodes01 dovecot-2.2.2]# make && make install

建立签名证书目录并运行脚本建立

[root@Nodes01 doc]# mkdir /etc/ssl/private    

[root@Nodes01 doc]# mkdir /etc/ssl/certs

[root@Nodes01 doc]# sh mkcert.sh

2.修改配置文件

/etc/dovecot.conf文件参数

protocols = imap pop3            发送邮件的协议

!include conf.d/*.conf

!include_try local.conf

/etc/dovecot/dovecot.d/10-mail.conf

mail_location = maildir:/mailbox/%d/%n/Maildir   邮件存储位置

namespace inbox {

 inbox = yes

}

/etc/dovecot/dovecot.d/10-auth.conf文件如下

disable_plaintext_auth = no

auth_mechanisms = plain

/etc/dovecot/dovecot-sql.conf.ext配置如下

driver = mysql

connect = host=/var/lib/mysql/mysql.sock  dbname=extmail user=extmail pas                                                                             sword=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 mailb                                                                             ox WHERE username='%u'

通过telnet连接测试

[root@Nodes01 ~]# telnet mail.longining.com 110

Trying 192.168.4.70...

Connected to mail.longining.com.

Escape character is '^]'.

+OK Dovecot ready.

user [email protected]

+OK

pass 123

+OK Logged in.                                   表明登录成功

3.dovecot测试出现的问题与解决方法

问题1:

Jun 05 23:04:13 auth: Fatal: mysql: Unknown connect string: default_pass_scheme

Jun 05 23:04:13 master: Error: service(auth): command startup failed, throttling for 4 secs

Jun 05 23:04:13 pop3-login: Info: Disconnected: Auth process broken (disconnected before auth was ready, waited 0 secs): user=<>, rip=::1, lip=::1, secured, session=<8GHFgmne0QAAAAAAAAAAAAAAAAAAAAAB>

分析:

 主要是dovecto_sql.ext文件配置错误

 connect=host=localhost  dbname=extmail user=extmail  password=extmail 后多了

 default_pass_scheme=CRYPT,并此选项要分两行。



问题2:

Jun 08 14:32:16 auth-worker(6262): Error: mysql(localhost ): Connect failed to database (extmail): Unknown MySQL server host 'localhost ' (3) - waiting for 125 seconds before retry

分析:

 connect = host=/var/lib/mysql/mysql.sock  dbname=extmail user=extmail  

 password=extmail,此行配置需注意,host为mysql.sock路径,同时后面后参数之间不

 能有多余的空格,否则会报错。


问题3:

Jun 08 14:48:16 auth-worker(6370): Error: mysql(/var/lib/mysql/mysql.sock): Connect failed to database (extmail): Access denied for user 'extmail '@'localhost

分析:

 user的extmail多了空格,删除即可。

五.部署邮件使用与管理界面

1.部署extmail

安装相关包

[root@Nodes01 mail]# tar -zxvf DBI-1.627.tar.gz

[root@Nodes01 DBI-1.627]# perl Makefile.PL

[root@Nodes01 DBI-1.627]# make && make install


[root@Nodes01 mail]# tar -zxvf DBD-mysql-4.023.tar.gz

[root@Nodes01 DBD-mysql-4.023]# perl Makefile.PL

[root@Nodes01 DBD-mysql-4.023]# make && make install


[root@Nodes01 mail]# tar -zxvf Unix-Syslog-1.1.tar.gz

[root@Nodes01 mail]# cd Unix-Syslog-1.1

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

[root@Nodes01 Unix-Syslog-1.1]# make && make install

解压安装

[root@Nodes01 html]# mv extmail-1.1.1/ extmail

[root@Nodes01 html]# tar -zxvf extmail-1.1.1.tar.gz -C /var/www/html/

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

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

extmail配置文件webmail.cf如下

SYS_CONFIG = /var/www/html/extmail/

SYS_LANGDIR = /var/www/html/extmail/lang

SYS_TEMPLDIR = /var/www/html/extmail/html

SYS_HTTP_CACHE = 0

SYS_SMTP_HOST = 127.0.0.1

SYS_SMTP_PORT = 25

SYS_SMTP_TIMEOUT = 5

SYS_SPAM_REPORT_ON = 0

SYS_SPAM_REPORT_TYPE = dspam

SYS_SHOW_WARN = 0

SYS_PERMIT_NOQUOTA = 1

SYS_SESS_DIR = /tmp

SYS_UPLOAD_TMPDIR = /tmp

SYS_LOG_ON = 1

SYS_LOG_TYPE = syslog

SYS_LOG_FILE = /var/log/extmail.log

SYS_SESS_TIMEOUT = 0

SYS_SESS_COOKIE_ONLY = 1

SYS_USER_PSIZE = 10

SYS_USER_SCREEN = auto

SYS_USER_LANG = en_US

SYS_APP_TYPE = WebMail

SYS_USER_TEMPLATE = default

SYS_USER_CHARSET = utf-8

SYS_USER_TRYLOCAL = 1

SYS_USER_TIMEZONE = +0800

SYS_USER_CCSENT = 1

SYS_USER_SHOW_HTML = 1

SYS_USER_COMPOSE_HTML = 1

SYS_USER_CONV_LINK =1

SYS_USER_ADDR2ABOOK = 1

SYS_MESSAGE_SIZE_LIMIT = 5242880

SYS_MIN_PASS_LEN = 2

SYS_MFILTER_ON = 1

SYS_NETDISK_ON = 1

SYS_SHOW_SIGNUP = 1

SYS_DEBUG_ON = 1

SYS_AUTH_TYPE = mysql

SYS_MAILDIR_BASE = /mailbox

SYS_AUTH_SCHEMA = virtual

SYS_CRYPT_TYPE = md5crypt

SYS_MYSQL_USER = extmail

SYS_MYSQL_PASS = extmail

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock

SYS_MYSQL_TABLE = mailbox

SYS_MYSQL_ATTR_USERNAME = username

SYS_MYSQL_ATTR_DOMAIN = domain

SYS_MYSQL_ATTR_PASSWD = password

SYS_MYSQL_ATTR_CLEARPW = clearpwd

SYS_MYSQL_ATTR_QUOTA = quota

SYS_MYSQL_ATTR_NDQUOTA = netdiskquota

SYS_MYSQL_ATTR_HOME = homedir

SYS_MYSQL_ATTR_MAILDIR = maildir

SYS_MYSQL_ATTR_DISABLEWEBMAIL = disablewebmail

SYS_MYSQL_ATTR_DISABLENETDISK = disablenetdisk

SYS_MYSQL_ATTR_DISABLEPWDCHANGE = disablepwdchange

SYS_MYSQL_ATTR_ACTIVE = active

SYS_MYSQL_ATTR_PWD_QUESTION = question

SYS_MYSQL_ATTR_PWD_ANSWER = answer

SYS_LDAP_BASE = o=extmailAccount,dc=example.com

SYS_LDAP_RDN = cn=Manager,dc=example.com

SYS_LDAP_PASS = secret

SYS_LDAP_HOST = localhost

SYS_LDAP_ATTR_USERNAME = mail

SYS_LDAP_ATTR_DOMAIN = virtualDomain

SYS_LDAP_ATTR_PASSWD = userPassword

SYS_LDAP_ATTR_CLEARPW = clearPassword

SYS_LDAP_ATTR_QUOTA = mailQuota

SYS_LDAP_ATTR_NDQUOTA = netdiskQuota

SYS_LDAP_ATTR_HOME = homeDirectory

SYS_LDAP_ATTR_MAILDIR = mailMessageStore

SYS_LDAP_ATTR_DISABLEWEBMAIL = disablewebmail

SYS_LDAP_ATTR_DISABLENETDISK = disablenetdisk

SYS_LDAP_ATTR_DISABLEPWDCHANGE = disablePasswdChange

SYS_LDAP_ATTR_ACTIVE = active

SYS_LDAP_ATTR_PWD_QUESTION = question

SYS_LDAP_ATTR_PWD_ANSWER = answer

SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

SYS_G_ABOOK_TYPE = file

SYS_G_ABOOK_LDAP_HOST = localhost

SYS_G_ABOOK_LDAP_BASE = ou=AddressBook,dc=example.com

SYS_G_ABOOK_LDAP_ROOTDN = cn=Manager,dc=example.com

SYS_G_ABOOK_LDAP_ROOTPW = secret

SYS_G_ABOOK_LDAP_FILTER = objectClass=OfficePerson

SYS_G_ABOOK_FILE_PATH = /var/www/html/extmail/globabook.cf

SYS_G_ABOOK_FILE_LOCK = 1

SYS_G_ABOOK_FILE_CONVERT = 0

SYS_G_ABOOK_FILE_CHARSET = utf-8

在apache中加入虚拟主机如下

NameVirtualHost mail.longining.com

<VirtualHost mail.longining.com>

ServerName mail.longining.com

#DirectoryIndex index.cgi,index.html

DocumentRoot /var/www/html/extmail/html/

ScriptAlias /extmail/cgi/ /var/www/html/extmail/cgi/

Alias /extmail /var/www/html/extmail/html/

</VirtualHost>

使用浏览器登录演示

在浏览器输入:mail.longining.com

问题:

浏览器访问时显示:系统信息 No such file or directory

方法:

[root@Nodes01 ~]# /var/www/html/extman/daemon/cmdserver -v -d


2.部署管理界面extman

安装相关包

[root@Nodes01 ~]# yum instlal -y rrdtool rrdtool-perl perl-GD

解压包并安装

[root@Nodes01 mail]# tar -zxvf extman-1.0.1.tar.gz -C /var/www/html/

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

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

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

[root@Nodes01 extman]# cp webman.cf.default webman.cf

extman配置文件webman.cf如下

SYS_CONFIG = /var/www/html/extman/

SYS_LANGDIR = /var/www/html/extman/lang

SYS_TEMPLDIR = /var/www/html/extman/html

SYS_MAILDIR_BASE = /mailbox

SYS_SHOW_WARN = 0

SYS_SESS_DIR = /tmp/extman/

SYS_CAPTCHA_ON = 1

SYS_CAPTCHA_KEY = r3s9b6a7

SYS_CAPTCHA_LEN = 6

SYS_PURGE_DATA = 0

SYS_PSIZE = 20

SYS_APP_TYPE = ExtMan

SYS_TEMPLATE_NAME = default

SYS_DEFAULT_EXPIRE = 1y

SYS_GROUPMAIL_SENDER = [email protected]

SYS_DEFAULT_SERVICES = webmail,smtpd,smtp,pop3,netdisk

SYS_ISP_MODE = no

SYS_DOMAIN_HASHDIR = yes

SYS_DOMAIN_HASHDIR_DEPTH = 2x2

SYS_USER_HASHDIR = yes

SYS_USER_HASHDIR_DEPTH = 2x2


SYS_MIN_UID = 500

SYS_MIN_GID = 100

SYS_DEFAULT_UID = 1000

SYS_DEFAULT_GID = 1000

SYS_QUOTA_MULTIPLIER = 1048576

SYS_QUOTA_TYPE = courier

SYS_DEFAULT_MAXQUOTA = 500

SYS_DEFAULT_MAXALIAS = 100

SYS_DEFAULT_MAXUSERS = 100

SYS_DEFAULT_MAXNDQUOTA = 500

SYS_USER_DEFAULT_QUOTA = 5

SYS_USER_DEFAULT_NDQUOTA = 5

SYS_USER_DEFAULT_EXPIRE = 1y

SYS_BACKEND_TYPE = mysql

SYS_CRYPT_TYPE = md5crypt

SYS_MYSQL_USER = webman

SYS_MYSQL_PASS = webman

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock

SYS_MYSQL_TABLE = manager

SYS_MYSQL_ATTR_USERNAME = username

SYS_MYSQL_ATTR_PASSWD = password

SYS_LDAP_BASE = dc=extmail.org

SYS_LDAP_RDN = cn=Manager,dc=extmail.org

SYS_LDAP_PASS = secret

SYS_LDAP_HOST = localhost

SYS_LDAP_ATTR_USERNAME = mail

SYS_LDAP_ATTR_PASSWD = userPassword

SYS_RRD_DATADIR = /var/lib

SYS_RRD_TMPDIR = /tmp/viewlog

SYS_RRD_QUEUE_ON = yes

SYS_CMDSERVER_SOCK = /tmp/cmdserver.sock

SYS_CMDSERVER_MAXCONN = 5

SYS_CMDSERVER_PID = /var/run/cmdserver.pid

SYS_CMDSERVER_LOG = /var/log/cmdserver.log

SYS_CMDSERVER_AUTHCODE = your_auth_code_here

SYS_IGNORE_SERVER_LIST = web

在apache加和如下内容

<VirtualHost man.longining.com>

ServerName man.longining.com

DocumentRoot /var/www/html/extman/

ScriptAlias /extman/cgi/ /var/www/html/extman/cgi/

Alias /extman /var/www/html/extman/html/

</VirtualHost>

使用浏览器登录演示

在浏览器输入:man.longining.com/extman/cgi/index.cgi


到此邮件服务搭建完成,在这个过程中postfix认证测试时错误较多,通过查找相关资料都一一解决,同时doovecot登录认证也是如此。希望此文对大家有所帮助,仅供参考。后面将实验拓展,如图形日志功能,extmail相关界面的修定与更改。


本文出自 “eagle” 博客,转载请与作者联系!

你可能感兴趣的:(linux,mysql,邮件服务器,Dovecot,邮件系统,客户端软件)