在 CentOS 上配置 sendmail 以允許從本地主機發送電子郵件
1.yum 安裝sendmail
$ yum install sendmail sendmail-cf
2.配置senmail
$ vim /etc/mail/sendmail.mc
設置: DAEMON_OPTIONS 配置爲僅允許從 localhost/smtp 發送: DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
設置: LOCAL_DOMAIN 選項設置爲您的主機名 or 域名: LOCAL_DOMAIN(`example.com')dnl
3.更新sendmail配置
$ sudo make -C /etc/mail
4.hostname 設置本地
$ vim /etc/hosts
加入:
127.0.0.1 localhost.localdomain localhost
5設置hostname 變量
$ vim /etc/sysconfig/network
加入:HOSTNAME=localhost.localdomain
6.重啓sendmail
$ sudo service sendmail restart.
參考文章:https://www.jeffgeerling.com/blogs/jeff-geerling/configure-sendmail-centos