3、与MySQL结合的配置及数据表结构
注意:配置mysql相关部分要写127.0.0.1而不要写localhost,如果使用localhost,postfix会尝试socket连接。debian的postfix使用socket连接好像有问题。mysql不能使用skip-networking选项,要使用--bind-address=127.0.0.1让它监听在127.0.0.1。(非常感谢MartinList-Petersen指点)
还有要注意的是如果是自己编译的mysql,建议在启动的时候加上--socket=/var/run/mysqld/mysqld.sock参数,因为pam-mysql又需要使用这个socket。如果你的apache+php是自己编译的话,php又需要重新编译,配置的时候需要加上--with-mysql-sock=/var/run/mysqld/mysqld.sock参数。
是不是比较烦?这不过是个开始。
MySQL的数据表:
以下为引用的内容: CREATETABLEalias( idint(11)unsignedNOTNULLauto_increment, aliasvarchar(128)NOTNULLdefault'', destinationvarchar(128)NOTNULLdefault'', PRIMARYKEY(id) )TYPE=MyISAM; CREATETABLErelocated( idint(11)unsignedNOTNULLauto_increment, emailvarchar(128)NOTNULLdefault'', destinationvarchar(128)NOTNULLdefault'', PRIMARYKEY(id) )TYPE=MyISAM; CREATETABLEtransport( idint(11)unsignedNOTNULLauto_increment, domainvarchar(128)NOTNULLdefault'', destinationvarchar(128)NOTNULLdefault'', PRIMARYKEY(id), UNIQUEKEYdomain(domain) )TYPE=MyISAM; CREATETABLEusers( idint(11)unsignedNOTNULLauto_increment, emailvarchar(128)NOTNULLdefault'', clearvarchar(128)NOTNULLdefault'', nametinytextNOTNULL, uidint(11)unsignedNOTNULLdefault'1011', gidint(11)unsignedNOTNULLdefault'1011', homedirtinytextNOTNULL, maildirtinytextNOTNULL, quotatinytextNOTNULL, postfixenum('Y','N')NOTNULLdefault'Y', PRIMARYKEY(id), UNIQUEKEYemail(email) )TYPE=MyISAM; CREATETABLEvirtual( idint(11)unsignedNOTNULLauto_increment, emailvarchar(128)NOTNULLdefault'', destinationvarchar(128)NOTNULLdefault'', PRIMARYKEY(id) )TYPE=MyISAM; /etc/postfix目录下各mysql配置文件: mysql-aliases.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=alias select_field=destination where_field=alias hosts=127.0.0.1 mysql-relocated.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=relocated select_field=destination where_field=email hosts=127.0.0.1 mysql-transport.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=transport select_field=destination where_field=domain hosts=127.0.0.1 |
以下为引用的内容: mysql-virtual.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=virtual select_field=destination where_field=email hosts=127.0.0.1 mysql-virtual-maps.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=users select_field=maildir where_field=email additional_conditions=andpostfix='y' hosts=127.0.0.1 mysql-virtual-uid.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=users select_field=uid where_field=email additional_conditions=andpostfix='y' hosts=127.0.0.1 mysql-virtual-gid.cf user=mysql-postfix-user password=mysql-postfix-pass dbname=postfix table=users select_field=gid where_field=email additional_conditions=andpostfix='y' hosts=127.0.0.1 修改Courier相关设置,/etc/courier/imapd: AUTHMODULES="authdaemon" IMAP_CAPABILITY="IMAP4rev1CHILDRENNAMESPACETHREAD=ORDEREDSUBJECT THREAD=REFERENCESSORTAUTH=CRAM-MD5AUTH=CRAM-SHA1IDLE" 修改/etc/courier/pop3d AUTHMODULES="authdaemon" POP3AUTH="LOGINCRAM-MD5CRAM-SHA1" 修改/etc/courier/authdaemonrc authmodulelist="authmysqlauthpam" 使用mysql验证和pam验证。 修改/etc/courier/authmysqlrc MYSQL_SERVER127.0.0.1 MYSQL_USERNAMEmysql-postfix-user MYSQL_PASSWORDmysql-postfix-pass #MYSQL_SOCKET/var/run/mysql/mysql.sock MYSQL_PORT0 MYSQL_OPT0 MYSQL_DATABASEpostfix MYSQL_USER_TABLEusers MYSQL_LOGIN_FIELDemail MYSQL_CLEAR_PWFIELDclear MYSQL_UID_FIELDuid MYSQL_GID_FIELDgid MYSQL_HOME_FIELDhomedir MYSQL_MAILDIR_FIELDmaildir SASLlibrary 创建/etc/postfix/sasl/smtpd.conf: pwcheck_method:PAM PAM-MySQL 创建/etc/pam.d/smtp: authoptionalpam_mysql.sohost=localhostdb=postfixuser= mysql-postfix-userpasswd=mysql-postfix-passtable=users usercolumn=emailpasswdcolumn=clearcrypt=n accountrequiredpam_mysql.sohost=localhostdb=postfixuser=mysql-postfix-userpasswd=mysql-postfix-passusercolumn=emailpasswdcolumn=clearcrypt=n |
(责任编辑:ken)