一、安裝sendmail與mail
1、安裝sendmail:
1) centos下可以安裝命令:
yum?-y?install?sendmail
2) 安裝完后啟動sendmail命令:
service?sendmail?start
(推薦教程:centos使用教程)
2、安裝mail
安裝命令:
yum?install?-y?mailx
二、發(fā)送郵件
1、通過文件內(nèi)容發(fā)送
發(fā)送命令:
mail?-s?'mail?test'?xxx@yyy.com?<p>?("mail test"為郵件主題,xxx@yyy.com為收件人郵箱,con.txt保存郵件內(nèi)容)<br></p><p>2、通過管道符直接發(fā)送</p><p>發(fā)送命令:</p><pre class="brush:php;toolbar:false">echo?"this?is?my?test?mail"?|?mail?-s?'mail?test'?xxx@yyy.com
三、設(shè)置發(fā)件人信息
上述發(fā)送郵件默認(rèn)會使用linux當(dāng)前登錄用戶信,通常會被當(dāng)成垃圾郵件,指定發(fā)件人郵箱信息命令:vi /etc/mail.rc,編輯內(nèi)容如:
set?from=username@126.com set?smtp=smtp.126.com set?smtp-auth-user=username set?smtp-auth-password=password set?smtp-auth=login
注意配置中的smtp-auth-password不是郵箱登錄密碼,是郵箱服務(wù)器開啟smtp的授權(quán)碼,每個郵箱開啟授權(quán)碼操作不同(網(wǎng)易126郵箱開啟菜單:設(shè)置-> 客戶端授權(quán)密碼)。
相關(guān)視頻教程推薦:centos使用教程
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載。
THE END
喜歡就支持一下吧
相關(guān)推薦