Extmail邮件服务器centos搭建(二)
3.3 postfix开启基于cyrus-sasl的认证查看sasl有关的安装包# rpm -qa |grep saslcyrus-sasl-md5-2.1.23-15.el6_6.2.x86_64cyrus-sasl-2.1.23-15.el6_6.2.x86_64cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64cyrus-sasl-gssapi-2.1.23-15.el6_6.2.x86_64cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_643.3.1postfix和sasl结合,编辑postfix配置文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# vim /etc/postfix/main.cf
#添加一下配置
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_banner = Welcome to our $myhostname SMTP
# service postfix restart
关闭 postfix: [确定]
启动 postfix: [确定]
# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 Welcome to our mail.aolens.cn ESMTP,Warning: Version not Available!
ehlo mail.aolens.cn
250-mail.aolens.cn
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH CRAM-MD5 DIGEST-MD5 PLAIN LOGIN GSSAPI
250-AUTH=CRAM-MD5 DIGEST-MD5 PLAIN LOGIN GSSAPI
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
3.3.2 sasl配置
1
2
3
4
5
6
7
8
9
# service saslauthd restart
停止 saslauthd: [确定]
正在启动 saslauthd: [确定]
# chkconfig --add saslauthd
# chkconfig saslauthd on
3.4安装Courier authentication library下载地址:http://www.courier-mta.org/download.html#authlib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# tar jxf courier-authlib-0.66.4.tar.bz2 -C /usr/local/src/
# cd /usr/local/src/courier-authlib-0.66.4/
# ./configure \
--prefix=/usr/local/courier-authlib \
--sysconfdir=/etc \
--with-authmysql \
--with-mysql-libs=/usr/lib64/mysql \
--with-mysql-includes=/usr/include/mysql \
--with-RedHat \
--with-authmysqlrc=/etc/authmysqlrc \
--with-authdaemonrc=/etc/authdaemonrc \
--with-mailuser=postfix
报错:configure: error: The Courier Unicode Library 1.2 appears not to be installed. You may need to install a separate development subpackage, in addition to the main package下载:courier-unicodehttps://sourceforge.net/projects/courier/files/courier-unicode/1.2/courier-unicode-1.2.tar.bz2/download
1
2
3
4
5
6
7
# tar jxf courier-unicode-1.2.tar.bz2
# cd courier-unicode-1.2
# ./configure
# make && make install && echo 1
再次编译courier-authlib就好了3.4.2 配置courier-authlib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon
# cp /etc/authdaemonrc.dist /etc/authdaemonrc
# cp /etc/authmysqlrc.dist /etc/authmysqlrc
# vim /etc/authdaemonrc
#authmodulelist="authuserdb authpwd authshadow authmysql authcustom authpipe”
#authmodulelistorig="authuserdb authpwd authshadow authmysql authcustom authpipe"
authmodulelist="authmysql"
authmodulelistorig="authmysql"
MYSQL_SERVER localhost
MYSQL_USERNAME root
MYSQL_PASSWORD aolens
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_PORT 3306
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
DEFAULT_DOMAIN aolens.cn
MYSQL_UID_FIELD '2525'
MYSQL_GID_FIELD '2525'
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/var/mailbox/',homedir)
MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)
# mkdir -pv /var/mailbox
mkdir: 已创建目录 "/var/mailbox"
# chown -R postfix.postfix /var/mailbox
为courier-authlib创建启动脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
# chmod +x /etc/init.d/courier-authlib
# chkconfig --add courier-authlib
# chkconfig courier-authlib on
# echo "/usr/local/courier-authlib/lib/courier-authlib/" >> /etc/ld.so.conf.d/courier-authlib.conf
# ldconfig
# service courier-authlib startStarting Courier authentication services: authdaemond
3.4.3配置smtp以及虚拟用户的相关创建smtpd.conf
1
2
3
4
5
6
7
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
编辑main.cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##postfix支持SMTP##
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
##postfix支持虚拟用户##
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
3.5 导入数据库使用extman源码目录下docs中的extmail.sql和init.sql建立数据库:下载extmail 和extmanhttp://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gzhttp://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz
1
# cp mysql_virtual_* /etc/postfix/
创建数据库
1
2
3
4
5
6
7
8
9
# mysql -uroot -p < extmail.sql
# mysql -uroot -p < init.sql
# service postfix restart
关闭 postfix: [确定]
启动 postfix: [确定]
3.6 配置dovecot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# vim /etc/dovecot/conf.d/10-mail.conf
#添加
mail_location = maildir:/var/mailbox/%d/%n/Maildir
# vim /etc/postfix/main.cf
#添加
home_mailbox = Maildir/
# cpauth-sql.conf.ext auth-sql.conf
# vim auth-sql.conf
#修改
passdb {
driver = sql
#args = /etc/dovecot/dovecot-sql.conf.ext
args = /etc/dovecot/dovecot-sql.conf
}
userdb {
driver = sql
#args = /etc/dovecot/dovecot-sql.conf.ext
args = /etc/dovecot/dovecot-sql.conf
}
创建dovecot-mysql.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# vim /etc/dovecot/dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=extmail user=root password=aolens
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'
# service dovecot start
正在启动 Dovecot Imap: [确定]
# chkconfig dovecot on
3.7 安装Extmail
1
2
3
4
5
6
7
# tar zxf extmail-1.2.tar.gz
# cp -a extmail-1.2 /var/www/extsuite/extmail
# cd /var/www/extsuite/extmail
# cp webmail.cf.default webmail.cf
3.7.2 修改主配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SYS_MESSAGE_SIZE_LIMIT = 5242880 #用户可以发送的最大邮件
SYS_USER_LANG = zh_CN #语言选择
SYS_MAILDIR_BASE =/var/mailbox #邮件存放位置
SYS_MYSQL_USER = root #数据库配置
SYS_MYSQL_PASS = aolens
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
3.8安装extman
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# cp -a extman-1.1 /var/www/extsuite/extman
# cp webman.cf.default webman.cf
# chown -R postfix.postfix /var/www/extsuite/extman/cgi
# chown -R postfix.postfix /var/www/extsuite/extmail/cgi
为extman创建临时目录
# mkdir /tmp/extman &&chown -R postfix.postfix /tmp/extman
# vim webman.cf
SYS_CAPTCHA_ON = 0 #修改1为0 验证码功能
# service postfix restart
关闭 postfix: [确定]
启动 postfix: [确定]
# service dovecot restart
停止 Dovecot Imap: [确定]
正在启动 Dovecot Imap: [确定]
# service saslauthd restart
停止 saslauthd: [确定]
正在启动 saslauthd: [确定]
3.9测试虚拟用户
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# /usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail
Authentication succeeded.
Authenticated: postmaster@extmail.org(uid 2525, gid 2525)
Home Directory: /var/mailbox/extmail.org/postmaster
Maildir: /var/mailbox/extmail.org/postmaster/Maildir/
Quota: (none)
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
Cleartext Password: extmail
Options: (none)
postmaster@extmail.org时init.sql里自带的4 安装perl依赖环境extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。
1
2
3
4
5
6
7
# tar zxf Unix-Syslog-1.0.tar.gz -C /usr/local/src/
# cd /usr/local/src/Unix-Syslog-1.0/
# perl Makefile.PL
# make && make install
4.2 配置apache虚拟主机
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# vim /etc/httpd/conf/httpd.conf
User postfix
Group postfix
<VirtualHost *:80>
ServerName mail.aolens.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
</VirtualHost>
# service httpd restart
访问mail.aolens.cn选择登陆邮箱管理:默认的账号密码是:root@extmail.org extmail*123*
添加域,添加用户使用普通用户登录报错:Can't chdir to /var/mailbox/aolens.cn/aolens/Maildir/, No such file or directory# vim /var/www/extsuite/extman/webman.cfSYS_MAILDIR_BASE = /var/mailboxSYS_MYSQL_USER = rootSYS_MYSQL_PASS = aolensSYS_MYSQL_DB = extmailSYS_MYSQL_HOST = localhostSYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock就是因为webman.cf没有设置导致创建用户后没有自动创建用户邮件存放路径。不启动cmdserver 的话系统页面会出现Connection refused
# ./cmdserver -dloaded ok现在尝试发送邮件:aaa@aolens.cn —> 312313231@qq.com邮件发送成功aaa@aolens.cn —> bbb@aolens.cn 发送不成功报错:mail postfix/smtpd: NOQUEUE: reject: RCPT from localhost: 550 5.1.1 <bbb@aolens.cn>: Recipient address rejected: User unknown in local recipient table; from=<aaa@aolens.cn> to=<bbb@aolens.cn> proto=ESMTP helo=<localhost.localdomain>修改main.cfmydestination = $myhostname邮件发送成功!
页:
[1]