1.yum install dovecot dovecot-mysql.x86_64 -y
##dovecot是一个开源的 IMAP 和 POP3 邮件服务器,支持 Linux,支持发送邮件
##dovecot-mysql是dovecot的插件,让dovecot识别MySQL
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服务
**测试
8.空壳邮件
vim /etc/postfix/main.cf
myorigin = westos.com ## 设置为真实的主机域名
mydestination = ##空壳邮件不接受邮件,所以不设置
relayhost = 172.25.254.174 ##接替的真实主机的IP
**测试
空壳主机给本机root发送邮件,174主机接收到邮件
本文转自 red777 51CTO博客,原文链接:http://blog.51cto.com/12314711/1930552