本文仅介绍Centos 7安装Postfix用于发送提醒邮件,并非搭建完整邮件服务器教程。

1. 卸载sendmail,没有安装sendmail的跳过

yum remove sendmail

2. 安装 Postfix

yum install postfix

3. 更改默认MTA为Postfix

/usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix

4. 检查是否将MTA改为Postfix

alternatives --display mta

5. 配置Postfix,修改main.cf

vi /etc/postfix/main.cf

查找以下各项,去掉最前面的#,参考说明修改

myhostname = www.ifshow.com
mydomain = ifshow.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relay_domains =
home_mailbox = Maildir/

myhostname是服务器的主机名,mydomain是域名,myorigin定义邮箱后缀,inet_interfaces是指定使用的网络接口,relay_domains是转发域留空,home_mailbox是指定邮箱格式。

6. 启动Postfix并设为开机自启

systemctl start postfix.service
systemctl enable postfix.service

到此完成配置,其它服务已经能够通过postfix发送提醒邮件。 由于只发邮件,所以防火墙不必开启POP3、SMTP等服务端口。