1. 卸载sendmail,没有安装sendmail的跳过centos
yum remove sendmail
2. 安装 Postfix服务器
yum install postfix
3. 更改默认MTA为Postfix网络
/usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix
4. 检查是否将MTA改成Postfixdom
alternatives --display mta
5. 配置Postfix,修改main.cfpost
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并设为开机自启rem
systemctl start postfix.service systemctl enable postfix.service
到此完成配置,其它服务已经可以经过postfix发送提醒邮件。
因为只发邮件,因此防火墙没必要开启POP三、SMTP等服务端口。域名
学习自:https://www.ifshow.com/centos-7-install-postfix-for-sending-e-mail-alerts/io
邮件服务器颇有必要。用来及时通知管理员服务器警报状况
后面再来补充一个代码报错实例