码迷,mamicode.com
首页 > 其他好文 > 详细

运维学习笔记虚拟用户邮件服务

时间:2016-08-22 23:40:17      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:邮件服务器   mysql   

DNS为邮件服务器做好域名解析后

注意:在做该实验时有些设备应关闭selinux

就可以利用MYSQL和POSTFIX来搭建数据库所记录的虚拟用户来使用邮件服务器进行收发邮件了

首先在MYSQL中建立email库存放记录虚拟用户信息的表emailuser

usernamepassworddomainmaildir

fu@redhat.com12345678redhat.com/redhat.com/fu/

MYSQL中新建用户并使得该用户只可访问email库

GRANT SELECT ON  email.* to postfixuser@localhost identified by ‘postfixuser‘;

新建用户并添加到postfix的主配置文件/etc/postfix/main.cf中

groupadd -g 451 vmail

useradd -s /bin/noligin -g 451 -u 451 vmail

postconf -e virtual_mailbox_base=/home/vmail

postconf -e virtual_uid_maps=static:451

postconf -e virtual_gid_maps=static:451

新建文件使数据库中信息与postfix关联

postconf -e virtual_alias_maps=mysql:/etc/postfix/my-emailuser.cf

postconf -e virtual_mailbox_domains=mysql:/etc/postfix/my-domain.cf

postconf -e virtual_mailbox_maps=mysql:/etc/postfix/my-maildir.cf

编辑文件my-emailuser.cf

|-   -|

   hosts = localhost

   user = postfixuser

   password = postfixuser

   dbname = email

   table = emailuser

   select_field = username

   where_field = username

|-   -|

编辑my-domain.cf

|-                         -|

   hosts = localhost

   user = postfixuser

   password = postfixuser

   dbname = email

   table = emailuser

   select_field = domain

   where_field = domain

|-                         -|

编辑my-maildir.cf

|-                         -|

   hosts = localhost

   user = postfixuser

   password = postfixuser

   dbname = email

   table = emailuser

   select_field = maildir

   where_field = username

|-                         -|

测试

postmap -q “fu@redhat.com” mysql:/etc/postfix/my-emailuser.cf

fu@redhat.com

postmap -q “redhat.com” mysql:/etc/postfix/my-domain.cf

redhat.com

postmap -q “test@westos.org” mysql:/etc/postfix/my-maildir.cf

/redhat.com/fu/

测试结果正确

reload postfix


本文出自 “饕餮鱼不要吃bug” 博客,转载请与作者联系!

运维学习笔记虚拟用户邮件服务

标签:邮件服务器   mysql   

原文地址:http://futianqi.blog.51cto.com/11557048/1841217

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!