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

3)编辑dovecot通过mysql认证的文件
[root@node1 conf.d]# vi /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'

——安装courier-authlib
1)下载安装courier-authlib
[root@node1 soft]# wget http:
//jaist.dl.sourceforge.net/project/courier/authlib/0.66.1/courier-authlib-0.66.1.tar.bz2
[root@node1 soft]# tar fvx courier-authlib-0.66.1.tar.bz2
[root@node1 soft]# cd courier-authlib-0.66.1
[root@node1 courier-authlib-0.66.1]# ./configure \
--prefix=/usr/local/courier-authlib \
    --sysconfdir=/etc \
    --without-authpam \
    --without-authshadow \
    --without-authvchkpw \
    --without-authpgsql \
    --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
[root@node1 courier-authlib-0.66.1]# make && make install

2)配置courier-authlib
[root@node1 courier-authlib-0.66.1]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
[root@node1 courier-authlib-0.66.1]# cp /etc/authdaemonrc.dist  /etc/authdaemonrc
[root@node1 courier-authlib-0.66.1]# cp /etc/authmysqlrc.dist  /etc/authmysqlrc
[root@node1 courier-authlib-0.66.1]# vi /etc/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
[root@node1 courier-authlib-0.66.1]# vi /etc/authmysqlrc
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_SOCKET            /var/lib/mysql/mysql.sock
MYSQL_PORT              3306
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD    password
DEFAULT_DOMAIN          test.com
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)

3)设置courier-authlib开机启动
[root@node1 courier-authlib-0.66.1]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@node1 courier-authlib-0.66.1]# chmod +x /etc/init.d/courier-authlib
[root@node1 courier-authlib-0.66.1]# chkconfig --add courier-authlib
[root@node1 courier-authlib-0.66.1]# chkconfig courier-authlib on
[root@node1 courier-authlib-0.66.1]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
[root@node1 courier-authlib-0.66.1]# ldconfig
[root@node1 courier-authlib-0.66.1]# service courier-authlib start
Starting Courier authentication services: authdaemond

4)设置smtpd认证
[root@node1 courier-authlib-0.66.1]# vi /usr/lib64/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket

5)配置postfix支持SMTP
1234567 [root@node1 dovecot]# vi /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
broken_sasl_auth_clients=yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous

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

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