redhat6使用SMTP發(fā)送郵件

1、關(guān)閉sendmail和postfix

1) sendmail

service sendmail stop
??chkconfig sendmail off #關(guān)閉開機(jī)啟動(dòng)

2) postfix

service postfix stop
??chkconfig postfix off

2、安裝mailx

redhat6上安裝mailx:
??yum install mailx

3、郵箱端配置(smtp服務(wù)可用網(wǎng)易或者QQ的,推薦使用QQ的smtp,網(wǎng)易經(jīng)常會(huì)出現(xiàn)554的報(bào)錯(cuò)而將郵件退回)

1) 使用網(wǎng)易郵箱SMTP服務(wù)

配置過程如下:
第一步:在163郵箱設(shè)置-->賬戶中開啟pop3/smtp服務(wù),并記下客戶端授權(quán)密碼
第二步:vim /etc/mail.rc 在文件最后添加你的郵箱信息:
使用網(wǎng)易SMTP服務(wù)(經(jīng)常被誤認(rèn)為垃圾郵件):
set from=150*@163.com
set smtp=smtp.163.com
set smtp-auth-user=150*@163.comset
smtp-auth-password=Your password (注意:此處為客戶端授權(quán)密碼)
set smtp-auth-login

2)使用QQ郵箱SMTP服務(wù)

獲取證書文件:
mkdir -p /root/.certs/
echo -n | openssl s_client -connect 14.18.245.164:465 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /.certs/qq.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
certutil -L -d /root/.certs

配置mail.rc:
vim /etc/mail.rc
set from=150*@qq.com
set smtp=14.18.245.164 ??????#smtp.qq.com對應(yīng)的ip(用于服務(wù)器不能連接外網(wǎng)解析域名的情況)
set smtp-auth-user=150*@qq.com
set smtp-auth-password=your passwd
set smtp-auth-login
set smtp-use-starttls
set ssl-verify=ignore
set nss-config-dir=/root/.certs

備注:如出現(xiàn)“Error initializing NSS: Unknown error -8015.”是因?yàn)橛脩魴?quán)限的問題。
解決辦法:chmod -R 777 /root/.certs

4、測試發(fā)送郵件:

echo "hello" |mailx -s 'test a mail' example.com
mailx -s 'test a mail' example.com <filename
(符號(hào)"<"和文件名之間千萬不要有空格,否則會(huì)被列為垃圾郵件)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容