# setenforce 0
# yum -y install mysql-server
# chkconfig mysqld on
# /etc/init.d/mysqld start
# /usr/bin/mysql_secure_installation
# useradd -u 600 -s /sbin/nologin email
# mysql -p

mysql> create database postfix;
mysql> use postfix;
mysql> create table email (username varchar(30), password varchar(30), domain varchar(30), mailbox varchar(30));
mysql> insert into email values ('william@gmail.com', 'westos', 'gmail.com', 'gmail.com/william/');
# vi /etc/postfix/mysql_virtual_alias_maps.cf
hosts = localhost
user = email
password = westos
dbname = postfix
table = email
select_field = username
where_field = username
# vi /etc/postfix/mysql_virtual_domain_maps.cf
hosts = localhost
user = email
password = westos
dbname = postfix
table = email
select_field = domain
where_field = domain
# vi /etc/postfix/mysql_virtual_mailbox_maps.cf
hosts = localhost
user = email
password = westos
dbname = postfix
table = email
select_field = mailbox
where_field = username
# postmap -q "william@gmail.com" mysql:/etc/postfix/mysql_virtual_alias_maps.cf
william@gmail.com
# postmap -q "gmail.com" mysql:/etc/postfix/mysql_virtual_domain_maps.cf
gmail.com
# postmap -q "william@gmail.com" mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
gmail.com/william/
# postconf -d | grep virtual
# postconf -e virtual_mailbox_base=/home/email/
# postconf -e virtual_uid_maps=static:600
# postconf -e virtual_gid_maps=static:600
# postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql_virtual_alias_maps.cf
# postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql_virtual_domain_maps.cf
# postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
# /etc/init.d/postfix restart
# mail william@gmail.com
# ls /home/email/gmail.com/william/

cur  new  tmp