1. 安装 Postfix
sudo yum install -y postfix
2.1 修改主配置文件
编辑 Postfix 的主配置文件 /etc/postfix/main.cf:
sudo vi /etc/postfix/main.cf
# 设置邮件服务器的主机名
myhostname = mail.yourdomain.com # 替换为你的域名
mydomain = yourdomain.com # 替换为你的域名
# 设置邮件投递的域名
myorigin = $mydomain
# 设置 Postfix 监听的网络接口
inet_interfaces = all
# 允许本地网络发送邮件(根据你的网络配置调整)--
mynetworks = 127.0.0.0/8, 192.168.1.0/24 # 替换为你的本地网络范围
# 允许接收的域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# 启用 SMTP 认证(如果需要)
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination