######################
### dovecot+ mysql ###
######################
1.yum install dovecot dovecot-mysql -y
##dovecot是一个开源的 IMAP 和 POP3 邮件服务器,支持 Linux,支持发送邮件
##dovecot-mysql是dovecot的插件,让dovecot识别MySQL
systemctl start httpd
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 ##开启明文认证
3. vim /etc/dovecot/conf.d/10-auth.conf
123 !include auth-sql.conf.ext ##开启MySQL认证方式
4. cp /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext
##生成dovecot读取MySQL配置
5.vim /etc/dovecot/dovecot-sql.conf.ext
32 driver = mysql ##数据库类型
71 connect = host=localhost dbname=email user=postuser password=123 ##查询用到的数据 库,用户和密码
78 default_pass_scheme = PLAIN ##默认认证方式为明文
107 password_query = \ ##查询密码匹配
108 SELECT username, domain, password \ ##查询用户,域名,密码
109 FROM emailuser WHERE username = '%u' AND domain = '%d' ##从emailuser表中查询
125 user_query = SELECT maildir, 666 AS uid, 666 AS gid FROM emailuser WHERE username ='%u' ##查询邮件内部内容
6. 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
7.systemctl restart dovecot.service ##重启dovecot服务
**测试
[root@foundation15 Desktop]# telnet 172.25.254.115 110
Trying 172.25.254.115...
Connected to 172.25.254.115.
Escape character is '^]'.
+OK [XCLIENT] Dovecot ready.
user lee@lee.com
+OK
pass lee
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
#########################
#### postfix 空壳邮件 ###
#########################
desktop.server的myorigin一样
~server
vim /etc/postfix/main.cf
75 myhostname = server ## 设置为真实的主机域名
83 mydomain = example.com
99 myorigin = $mydomain
113 inet_interfaces = all
164 mydestination = ##空壳邮件不接受邮件,所以不设置
316 relayhost = 172.25.254.115 ##接替的真实主机的IP
systemctl restart postfix.service
~desktop
myhostname = desktop
mydomain = westos.com
myorigin = example.com
~server
mail root@westos.com
server是desktop的空壳,
**测试
空壳主机给本机root发送邮件,174主机接收到邮件