1.卸載sendmail與postfix
yum -y install mailx
2.安裝mailx
yum -y remove sendmail postfix
3.配置mail.rc
vim /etc/mail.rc set from="dingkaitest@163.com" #用來發送郵件的郵箱 set smtp=smtp.163.com #163的郵件發送服務器 set smtp-auth-user=dingkaitest #郵箱用戶名(也可以寫成"dingkaitest@163.com") set smtp-auth-password=密碼 #郵箱密碼 set smtp-auth=login
4.測試發送
echo "hello,world"|mailx -v -s "test" 目標郵箱
注:
某些廠商雲服務器可能封掉了25端口,需要解封。