mailx 使用ssl郵件傳送配置 2018-12-28

weixin_34292287發表於2018-12-28

先安裝mailx
yum install mailx
編輯配置檔案
vim /etc/mail.rc
追加以下內容

set from=example@qq.com
set smtp=smtps://smtp.qq.com:465                                              
set smtp-auth-user=example@qq.com
set smtp-auth-password=**************
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set from=example@qq.com 傳送郵箱
set smtp=smtps://smtp.qq.com:465 發件伺服器
set smtp-auth-user=example@qq.com 發件使用者名稱
set smtp-auth-password=************** 郵箱密碼或授權碼
set smtp-auth=login 連線方式,用login即可
set ssl-verify=ignore 啟用ssl
set nss-config-dir=/root/.certs 證書位置

證書配置

mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.qq.com: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 -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i qq.crt
certutil -L -d /root/.certs

測試傳送郵件
echo "郵件正文" | mail -s "郵件主題" example@qq.com

相關文章