第三本书 postfix&mysql dovecot&mysql

来源:互联网 发布:java程序员个人评价 编辑:程序博客网 时间:2024/04/29 00:03
######postfix与mariadb######


yum install httpd php php-mysql mariadb-server -y


systemctl start httpd
systemctl start mariadb
(1)调配数据库
mysql_secure_installation


mysql -uroot -pwestos

create user postuser@locathost identified by 'postuser';  ##添加postuser用户密码为postuser


grant select,insert,update on email.* to postuser@localhost   ##为postuser在email库增加权限


调配php数据库,可以在网页上登陆


cd /var/www/html
tar jxf phpMyAdmin_3.4.0-all-languages.tar.bz2 ##解压
mv phpMyAdmin_3.4.0-all-languages/  mysqladmin ##改名为mysqladmin
cd mysqladmin
cp -p config.sample.inc.php  config.inc.php
vim config.inc.php


打开浏览器进入172.25.254.130/mysqladmin调配数据库


调配完成后
(2)调配postfix
cd/etc/postfix


vim /etc/postfix/emailuser.cf ##用户名称查询
hosts = localhost ##数据库所在主机
user = postuser ##登陆数据库的用户
password = postuser ##登陆数据库的密码
dbname = email ##postfix要查询的库的名称
table = emailuser ##postfix要查询的表的名称
select_field = username ##postfix要查询的字段
where_field = username ##用户给定postfix的查询条件


vim /etc/postfix/emaildomian.cf ##用户域名查询
hosts = localhost
user = postuser
password = postuser
dbname = email
table = emailuser
select_field = domain
where_field = domain


vim /etc/postfix/mailbox.cf ##用户邮箱位置查询
hosts = localhost
user = postuser
password = postuser
dbname = email
table = emailuser
select_field = maildir
where_field = username


测试
[root@mail postfix]# postmap -q "zxh@zxh.com" mysql:/etc/postfix/mailuser.cf 
zxh@zxh.com
[root@mail postfix]# postmap -q "zxh.com" mysql:/etc/postfix/maildomain.cf 
zxh.com
[root@mail postfix]# postmap -q "zxh@zxh.com" mysql:/etc/postfix/mailbox.cf
/mnt/zxh.com/zxh

\

groupadd -g 666 vmail##建立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"##读取数据库用户
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf"##读取数据库域
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"##读取数据库邮箱


进入浏览器更改maildir


测试mail zxh@zxh.com
cd /home/vmail/zxh.com/zxh/new





#####dovecot&mysql####
实验前需先配置好westos.com与qq.com两台虚拟机,php
1.
yum install dovecot dovecot-mysql -y  
2.
vim  /etc/dovecot/dovecot.conf
  24 protocols = imap pop3 lmtp ##支持的收件协议
  48 login_trusted_networks = 0.0.0.0/0 ##信任网络
  49 disable_plaintext_auth = no ##开启明文认证


vim /etc/dovecot/conf.d/10-auth.conf
 123 !include auth-sql.conf.ext ##开启mysql的认证方式


#生成dovecot读取mysql的配置
cp /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext  /etc/dovecot/dovecot-sql.conf.ext


vim  /etc/dovecot/dovecot-sql.conf.ext
  32 driver = mysql ##数据库类型
  71 connect = host=localhost dbname=email user=postuser password=postuser##查询时用到的库,用户,密码
  78 default_pass_scheme =PLAIN ##默认认证方式为明文
  107 password_query = \ ##查询密码匹配
  108    SELECT  username, domain, password \

  109    FROM emailuser WHERE username = '%u' AND domain = '%d'


  125 user_query = SELECT maildir, 666 AS uid, 666 AS gid FROM emailuser WHERE username = '%u'


vim /etc/dovecot/conf.d/10-mail.conf

  30 mail_location = maildir:/home/vmail/%d/%n##指定邮件位置


  168 first_valid_uid = 666##邮件文件查询用户身份
  175 first_valid_gid = 666


systemctl restart dovecot


测试
[root@foundation30 network-scripts]# telnet 172.25.254.130 110
Trying 172.25.254.130...
Connected to 172.25.254.130.
Escape character is '^]'.
+OK [XCLIENT] Dovecot ready.
user zxh@zxh.com
+OK
pass postuser
+OK Logged in.


在雷鸟中登陆zxh@zxh.com查看邮件


####空壳邮箱####
以172.25.254.230 qq.com作为空壳邮箱,在其中
vim  /etc/postfix/main.cf
99 myorigin = westos.com
164 mydestination = 
316 relayhost = 172.25.254.130


systemctl restart postfix
测试
mail root

在172.25.254.130 westos.com中可收到测试邮件



阅读全文
0 0
原创粉丝点击