首页 > 代码库 > postfix+mysql

postfix+mysql

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/里找到

技术分享

技术分享


postfix+mysql