vim /etc/postfix/main.cf,添加如下内容:
########################Virtual Mailbox Settings########################
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
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
##########################QUOTA Settings########################
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.
virtual_overquota_bounce = yes
2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库:
tar zxvf extman-1.1.tar.gz
cd extman-1.1/docs
mysql -u root -p <extmail.sql
mysql -u root -p <init.sql
mysql -u root -p 验证是否建立的extmail数据库
cp mysql* /etc/postfix/
3、授予用户extmail访问extmail数据库的权限
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>FLUSH PRIVILEGES; 让设置的内容立即生效
七、配置dovecot
1、配置dovecot的主配置文件/etc/dovecot.conf
vim /etc/dovecot.conf
mail_location = maildir:/var/mailbox/%d/%n/Maildir
找到对应的项进行如下修改
auth default {
mechanisms = plain
passdb sql {
args = /etc/dovecot-mysql.conf
}
userdb sql {
args = /etc/dovecot-mysql.conf
}
重新加载postfix服务
postfix reload
2 、创建dovecot和mysql数据库连接文件/etc/dovecot-mysql.conf
vim /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'
3、启动dovecot服务:
service dovecot start
chkconfig dovecot on