Centos 7安裝Postfix用於發送提醒郵件

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

郵件服務器頗有必要。用來及時通知管理員服務器警報狀況

後面再來補充一個代碼報錯實例

相關文章
相關標籤/搜索