Centos 配置mailx使用外部smtp发送邮件
今天寫定時(shí)腳本時(shí),用到監(jiān)控服務(wù)器是否備份成功,配置sentmail和postfix總是出問題,原本想只是接受個(gè)信息,沒必要那么麻煩,直接配置mailx就能滿足了,具體配置如下:
1、安裝mailx
yum install mailx -y?
2、編輯發(fā)送的配置文件(修改/etc/mail.rc)
vi /etc/mail.rc
#qq.com
set smtp=smtp.qq.com?? ?//郵箱所在服務(wù)器和端口地址
set from="1147076062@qq.com" ?//你的qq郵箱
set smtp-auth-user="1147076062@qq.com" smtp-auth-password="bqh***" ?//郵箱密碼
set smtp-auth=login? //默認(rèn)login即可
echo "郵件正文" | mail -s "郵件主題" 1147076062@qq.com
發(fā)送文件的另外幾種格式:
cat file.txt | mail -s "郵件主題" 1147076062@qq.com
mail -s "郵件主題" 1147076062@qq.com < file.txt
echo? hello 錦衣衛(wèi) | mail -s "測試" 1147076062@qq.com
溫馨提醒:
①記得要進(jìn)郵箱打開SMTP。
②關(guān)閉本機(jī)的sendmail服務(wù)或者postfix服務(wù)等。
③smtp-auth-password="bqh***" 此處是配置授權(quán)碼,而不是郵箱的獨(dú)立密碼。如果配置錯(cuò)了會(huì)報(bào)錯(cuò)
(smtp-server: 535 Error: ??????μ???£Ъ???′: http://service.mail.qq.com/cgi-b
in/help?subtype=1&&id=28&&no=1001256"/root/dead.letter" 11/303
. . . message not sent.)
---------------------------------------------------------------------------------------------------------
想讓服務(wù)器自動(dòng)發(fā)個(gè)郵件至163郵箱或者qq郵箱等,可以配置mailx使用外部smtp發(fā)送郵件,要是想做郵件服務(wù)器的話可以用sentmail和postfix等。
轉(zhuǎn)載于:https://www.cnblogs.com/su-root/p/10092469.html
總結(jié)
以上是生活随笔為你收集整理的Centos 配置mailx使用外部smtp发送邮件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql与Json学习总结
- 下一篇: PHP -Casbin: 支持 ACL、