CentOS7安裝郵件服務(wù)器完整教程
準(zhǔn)備工作
確保系統(tǒng)已更新:
yum update -y
hostnamectl set-hostname mail.yourdomain.com
systemctl stop firewalld
systemctl disable firewalld
安裝必要組件
安裝Postfix與Dovecot:
yum install -y postfix dovecot cyrus-sasl
配置Postfix服務(wù)
編輯主配置文件:
vi /etc/postfix/main.cf
關(guān)鍵配置參數(shù):
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
配置Dovecot服務(wù)
修改認(rèn)證配置:
vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login
SSL證書(shū)配置
使用Let's Encrypt申請(qǐng)證書(shū):
yum install certbot -y
certbot certonly --standalone -d mail.yourdomain.com
DNS記錄設(shè)置
- MX記錄:mail.yourdomain.com 優(yōu)先級(jí)10
- A記錄:mail.yourdomain.com 指向服務(wù)器IP
- PTR記錄:IP反向解析到域名
服務(wù)啟動(dòng)與驗(yàn)證
systemctl start postfix dovecot
systemctl enable postfix dovecot
telnet localhost 25
安全加固建議
- 啟用fail2ban防御暴力破解
- 定期更新SSL證書(shū)
- 配置SPF/DKIM/DMARC記錄
- 監(jiān)控/var/log/maillog日志文件