之前
pop,imap
↓
postfix→sasl→authdamond→authuserdb
之后
pop,imap
↓
postfix→sasl→authdamond→authmysql
让authdamond使用authmysql
apt-get install postfix-mysql
(1)修改authdaemonrc
(2)安装courier-authmysql
(3)main.cf的修改
(4)数据库表的建立
(1)authmodulelist="authmysql"
(2)apt-get install courier-authmysql
(3)virtual_mailbox_domains = mysql:/etc/postfix/mysql-vd.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
(4)一个domain表,一个mailbox表
+----------------+
| virtual_domain |
+----------------+
| sosogh.com |
| my.com |
+----------------+
+-------------------+----------+--------+----------------------------+
| username | password | name | maildir |
+-------------------+----------+--------+----------------------------+
|
sosogh@sosogh.com | 123456 | sosogh | sosogh.com/sosogh/Maildir/ |
+-------------------+----------+--------+----------------------------+
(5)/etc/postfix/mysql-vd.cf的内容
user = postfix
password = postfix
dbname = postfix
table = virtual_domain
select_field = virtual_domain
where_field = virtual_domain
hosts = 127.0.0.1
/etc/postfix/mysql_virtual_mailbox_maps.cf的内容
user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
/etc/courier/authmysqlrc的内容
MYSQL_SERVER 127.0.0.1
MYSQL_USERNAME postfix
MYSQL_PASSWORD postfix
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_OPT 0
MYSQL_DATABASE postfix
MYSQL_USER_TABLE mailbox
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 108
MYSQL_GID_FIELD 108
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD '/vmail/'
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
注意/etc/courier/authmysqlrc的格式要求很严格,不能有多的whitespace 在值的后面
MYSQL_HOME_FIELD '/vmail/'中的一对单引号也很重要