1 安裝相關的軟體包:
[root@ansible ~]# uname -r
3.10.0-123.9.3.el7.x86_64
[root@ansible ~]# yum -y install sendmail mailx
2 修改host檔案,本機IP為192.168.1.12:
[root@ansible ~]# hostname
ansible
[root@ansible ~]# vim /etc/hosts
192.168.1.12 ansible localhost.localdomain
3 重新開機sendmail服務:
[root@ansible ~]# systemctl restart sendmail.service
4 測試郵件發送,-s為标題,内容需要手動輸入,然後按Enter鍵,ctrl+d結束輸入:
[root@ansible ~]# mail -s "a" [email protected]
dd
EOT
上面發送郵件的方式,是在沒有公網域名解析下的權宜之計,用這種方式任何一台Linux伺服器都可以向外發送郵件,ansible是用在内網解析的計算機名稱。
本文轉自 zengwj1949 51CTO部落格,原文連結:http://blog.51cto.com/zengwj1949/1942737