邮件服务器搭建之:详解Dovecot配置

Dovecot是一个安全性较好的POP3/IMAP服务器软件,响应速度快而且扩展性好
POP3 / IMAP 是 MUA 从邮件服务器中读取邮件时使用的协议。其中,POP3是从邮件服务器中下载邮件,而IMAP则是将邮件留在服务器端直接对邮件进行管理、操作。
Dovecot使用PAM方式( Pluggable Authentication Module,可插拔认证模块)进行身份认证,以便识别并验证系统用户,通过认证的用户才允许从邮箱中收取邮件。对于RPM方式安装的dovecot,会自动建立该PAM文件
RHEL6系统自带了Dovecot软件,可通过yum之间安装

[root@rhel6 ~]# yum -y install dovecot* 
[root@rhel6 ~]# vi /etc/dovecot/dovecot.conf  
protocols = imap pop3  //使用的协议
login_trusted_networks = 192.168.0.0/24                         //设置允许连接的地址 
!include conf.d/*.conf                                          //说明conf.d下的所以conf结尾的文件均有效 
 
[root@rhel6 ~]# cat /etc/dovecot/conf.d/10-mail.conf  //设置邮件存放的路径
mail_location = mbox:~/mail:INBOX=/var/mail/%u 

基础的 POP3/IMAP 设置

[root@rhel6 ~]# vi /etc/dovecot/conf.d/10-ssl.conf  
ssl = no                                                         //关闭SSL加密 
[root@rhel6 ~]# /etc/init.d/dovecot restart         
[root@rhel6 ~]# netstat -lntp | grep dovecot                        //只开放了110、143端口 
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      2434/dovecot         
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      2434/dovecot         
tcp        0      0 :::110                      :::*                        LISTEN      2434/dovecot         
tcp        0      0 :::143                      :::*                        LISTEN      2434/dovecot 

发送一封邮件给rhce@rhel6.xfcy.org用户,到windows系统通过outlook接收邮件进行测试:
[root@rhel6 ~]# mail -s 'postfix' rhce@rhel6.xfcy.org < /etc/hosts

加密的POP3s/IMAPs设置

[root@rhel6 ~]# vi /etc/dovecot/conf.d/10-auth.conf  
disable_plaintext_auth = yes                                        //设置密文传输 
 
[root@rhel6 ~]# vi /etc/dovecot/conf.d/10-ssl.conf  
ssl=required  //开启SSL
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem  //公钥路径
ssl_key = </etc/pki/dovecot/private/dovecot.pem  //私钥路径
 
[root@rhel6 ~]# vi /etc/dovecot/conf.d/10-master.conf  
service imap-login { 
  inet_listener imap { 
    port = 0 
  } 
  inet_listener imaps { 
    #port = 993 
    #ssl = yes 
  } 
} 
 
service pop3-login { 
  inet_listener pop3 { 
    port = 0 
  } 
  inet_listener pop3s { 
    #port = 995 
    #ssl = yes 
  } 
} 
                                      
[root@rhel6 ~]# /etc/init.d/dovecot restart          
[root@rhel6 ~]# netstat -lntp | grep dovecot         
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      2547/dovecot         
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      2547/dovecot         
tcp        0      0 :::993                      :::*                        LISTEN      2547/dovecot         
tcp        0      0 :::995                      :::*                        LISTEN      2547/dovecot 
原文地址:https://www.cnblogs.com/enumx/p/12416769.html