1.2实现基于虚拟用户的邮件系统架构(3)

6)配置postfix支持虚拟用户
[root@node1 courier-authlib-0.66.1]# vi /etc/postfix/main.cf
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

——安装Extmail
1)创建相关目录并解压extmail
[root@node1 soft]# mkdir -p /var/www/extsuite
[root@node1 soft]# tar fzvx extmail-1.2.tar.gz -C /var/www/extsuite/
[root@node1 soft]# cp /var/www/extsuite/extmail-1.2 /var/www/extsuite/extmail
[root@node1 soft]# cd /var/www/extsuite/extmail

2)修改Extmail的主配置文件

[root@node1 extmail]# cp webmail.cf.default webmail.cf
[root@node1 extmail]# vi webmail.cf
SYS_SESS_DIR = /tmp/extmail
SYS_UPLOAD_TMPDIR = /tmp/extmail/upload
SYS_USER_LANG = zh_CN
SYS_MIN_PASS_LEN = 8
SYS_MAILDIR_BASE = /var/mailbox
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_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

3)建立extmail的临时文件目录及session目录

[root@node1 extman]# mkdir -p /tmp/extmail/upload
[root@node1 extman]# chown postfix.postfix -R /tmp/extmail/

——安装Extman

1)解压extmail
[root@node1 soft]# tar fzvx extman-1.1.tar.gz -C /var/www/extsuite/
[root@node1 soft]# cd /var/www/extsuite/extmail
[root@node1 extsuite]# mv extman-1.1 extman
[root@node1 extsuite]# cd extman

2)修改Extman的主配置文件
[root@node1 extman]# cp webman.cf.default webman.cf
[root@node1 extman]# vi webman.cf
SYS_MAILDIR_BASE = /var/mailbox
SYS_DEFAULT_UID = 2525
SYS_DEFAULT_GID = 2525
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock

3)修改cgi目录的属主
[root@node1 extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/
[root@node1 extman]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

4)导入Extman的数据库

[root@node1 extman]# cd docs/
[root@node1 docs]# vi extmail.sql
将文件里面所有的TYPE=MyISAM改为ENGINE=MyISAM、命令如下:
:% s/TYPE/ENGINE/g  共有5处
[root@node1  docs]# sed -i 's/extmail.org/test.com/g' init.sql
[root@node1  docs]# sed -i 's/1000/2525/g' init.sql
[root@node1 docs]# mysql -u root < extmail.sql
[root@node1 docs]# mysql -u root < init.sql

5)授予用户extmail访问extmail数据库的权限
[root@node1 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 79
Server version: 5.6.29 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
mysql> GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';
mysql> quit
Bye

6)为Extman创建临时目录并给予权限
[root@node1 docs]# mkdir /tmp/extman
[root@node1 docs]# chown postfix.postfix -R /tmp/extman/

——重启postfix、dovecot、saslauthd、nginx
[root@node1 docs]# service postfix restart
[root@node1 docs]# service dovecot restart
[root@node1 docs]# service saslauthd restart

——测试虚拟用户实现结果
1)测试Postfix 支持虚拟用户
[root@node1 docs]# /usr/local/courier-authlib/sbin/authtest -s login postmaster@test.com extmail
Authentication succeeded.        //  表示成功
      Authenticated: postmaster@test.com  (uid 2525, gid 2525)
    Home Directory: /mailbox/test.com/postmaster
            Maildir: /mailbox/test.com/postmaster/Maildir/
                Quota: (none)
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
Cleartext Password: extmail
            Options: (none)
2)测试虚拟用户SMPT发信认证
[root@node1 docs]# printf  "postmaster@test.com" | openssl base64
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@node1 docs]# printf  "extmail" | openssl base64
ZXh0bWFpbA==
[root@node1 docs]#
[root@node1 docs]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.benet.com ESMTP Postfix
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.0.0 Authentication successful      //  表示成功
quit
221 2.0.0 Bye
Connection closed by foreign host.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9f3222fbda9a33357b5fd76eb192eda3.html