資安

Centos 7下如何配置SMTP SSL(郵箱發送功能)

1.安裝openssl
yum install -y openssl openssl-devel
2.安裝mailx
yum -y install mailx
3.啟用SSL功能
mkdir -p /root/.certs/
cd $HOME
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 -L -d /root/.certs
說明:在執行以上命令過程中,如果沒有出現錯誤提示,說明操作成功;否則需要把這個問題解決才能做後面的操作
4.配置mail.rc文件
vim /etc/mail.rc

在mail.rc文件末尾增加如下內容(騰訊雲企業郵箱群組賬號和密碼)
image.png

set from=
set smtp=smtps://smtp.exmail.qq.com:465
set smtp-auth-user=
set smtp-auth-password=
set smtp-auth=login

set ssl-verify=ignore
set nss-config-dir=/root/.certs
5.測試驗證
echo "hello,world" |mailx -v -s "test from huanwei" [email protected]
image.png
如上截圖表示測試郵件發送成功
6.查收郵件

Leave a Reply

Your email address will not be published. Required fields are marked *