天天看點

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檔案末尾增加如下内容(騰訊雲企業郵箱群組賬号和密碼)

Centos 7下如何配置SMTP SSL(郵箱發送功能)
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]

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

如上截圖表示測試郵件發送成功

6.查收郵件

繼續閱讀