dovecot virtual user

 

 

dovecot.conf

# Virtual mail accounts.
userdb {
    args = /usr/local/etc/dovecot/dovecot-mysql.conf
    driver = sql
}
passdb {
    args = /usr/local/etc/dovecot/dovecot-mysql.conf
    driver = sql
}

建立 Table

CREATE USER 'vmail'@'localhost' IDENTIFIED BY '??????';
GRANT USAGE ON *.* TO 'vmail'@'127.0.0.1';
GRANT ALL  ON `vmail`.* TO 'vmail'@'127.0.0.1' WITH GRANT OPTION;
FLUSH PRIVILEGES;

USE `vmail`;

CREATE TABLE mailbox (
    email VARCHAR(128) NOT NULL,
    password VARCHAR(64) NOT NULL,
    active TINYINT(1) NOT NULL DEFAULT '1',
    remark VARCHAR(255)
);
 

dovecot-mysql.conf

-r-xr-x---  1 root    root     749 Apr 29  2013 dovecot-mysql.conf

driver = mysql
default_pass_scheme = CRYPT
connect = host=127.0.0.1 dbname=vmail user=vmail password=????????

# Required by 'doveadm mailbox ...'.
iterate_query = SELECT email AS user FROM mailbox

password_query = SELECT password FROM mailbox WHERE email='%u' AND active='1'

user_query = SELECT \
             CONCAT('/home/vmail/', '%d', '/','%u') AS home \
             FROM mailbox \
             WHERE email='%u' AND active=1

 

 

Creative Commons license icon Creative Commons license icon