1.配置mysql
实验之前,制作要使用数据库和表
添加数据库用户,并给其授权
* vim /etc/postfix/mailuser.cf ##查询用户名
1 host = localhost ##数据库主机
2 user = postuser ##登录数据库用户
3 password = 123 ##登录密码
4 dbname = email ##postfix查询库的名称
5 table = emailuser ##postfix查询表的名称
6 select_field = username ##postfix查询的字段
7 where_field = username ##给postfix查询的条件
* vim /etc/postfix/maildomain.cf ##域名查询
1 host = localhost
2 user = postuser
3 password = 123
4 dbname = email
5 table = emailuser
6 select_field = domain
7 where_field = domain
vim /etc/postfix/mailbox.cf
1 host = localhost
2 user = postuser
3 password = 123
4 dbname = email
5 table = emailuser
6 select_field = maildir
7 where_field = username
测试
2.配置postfix
groupadd -g 666 vmail ##添加用户组并指定gid为666
useradd -s /sbin/nologin -u 666 vmail -g 666 ##添加用户,并指定uid和gid为666
* postconf -e "virtual_mailbox_base = /home/vmail" ##设定虚拟用户邮件目录
postconf -e "virtual_uid_maps = static:666" ##指定虚拟用户建立文件uid
postconf -e "virtual_gid_maps = static:666" ##指定虚拟用户建立文件gid
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf" ##指定MySQL查找主机
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf" ##指定MySQL查找域名
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf" ##指定MySQL查找邮箱
*systemctl restart postfix ##重启postfix服务
测试
发送给linux@linux.com的邮件在/home/vmail/linux/new/里找到
本文转自 漂浮的天堂 51CTO博客,原文链接:http://blog.51cto.com/12774215/1929522,如需转载请自行联系原作者