Linux与云计算——第二阶段Linux服务器架设
第九章:Mail电子邮件服务器架设—postfix和Dovecot
安装Postfix
安装Postfix来配置SMTP服务器. SMTP使用25/TCP.
[1] Postfix 是CentOS系统默认安装,哪怕你选择了最小安装,如果确认没有安装,请先安装.
[[email protected] ~]# yum -y install postfix
[2] 使用Dovecot‘s SASL 来配置SMTP认证。
[[email protected] ~]# vi /etc/postfix/main.cf
# line 75: 去掉注释并修改主机名
myhostname = mail.example.com
# line 83: 去掉注释并且定义域名
mydomain = example.com
# line 99: 去掉注释
myorigin = $mydomain
# line 116: 修改
inet_interfaces = all
# line 164: 添加
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# line 264: 去掉注释并且按照你本地局域网环境修改
mynetworks = 127.0.0.0/8, 192.168.96.0/24
# line 419: 去掉注释 (use Maildir)
home_mailbox = Maildir/
# line 574: 添加
smtpd_banner = $myhostname ESMTP
# 在最后面添加以下内容
# limit an email size for 10M
message_size_limit = 10485760
# limit a mailbox for 1G
mailbox_size_limit = 1073741824
# for SMTP-Auth
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
[[email protected] ~]# systemctl restart postfix
[[email protected] ~]# systemctl enable postfix
安装Dovecot
安装Dovecot来配置POP/IMAP服务器。POP使用110/TCP, IMAP使用143/TCP.
[1] Install Dovecot.
[[email protected] ~]# yum -y install dovecot
[2] provide SASL function to Postfix.
[[email protected] ~]# vi /etc/dovecot/dovecot.conf
# line 24: 去掉注释
protocols = imap pop3 lmtp
# line 30: 去掉注释并修改 ( 如果不使用IPv6 )
listen = *
[[email protected] ~]# vi /etc/dovecot/conf.d/10-auth.conf
# line 10: 去掉注释并修改 ( 允许明文认证 )
disable_plaintext_auth = no
# line 100: 增加
auth_mechanisms = plain login
[[email protected] ~]# vi /etc/dovecot/conf.d/10-mail.conf
# line 30: 去掉注释并添加
mail_location = maildir:~/Maildir
[[email protected] ~]# vi /etc/dovecot/conf.d/10-master.conf
# line 96-98: uncomment and add like follows
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
[[email protected] ~]# vi /etc/dovecot/conf.d/10-ssl.conf
# line 8: 修改 (不使用SSL)
ssl = no
[[email protected] ~]# systemctl start dovecot
[[email protected] ~]# systemctl enable dovecot