阿里云爲了防止垃圾郵件氾濫,將25端口禁用了,下面給出解決辦法
安裝對應的數字證書:這裏請求安裝網易126郵箱數字證書,也可以安裝別的證書
一:126郵箱證書安裝
mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.126.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/126.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt
certutil -L -d /root/.certs
接下來是安裝mailx,安裝mailx前關閉postfix
二:在配置文件 vim /etc/mail.rc 末尾添加郵箱相關授權信息
set [email protected] #開啓SMTP服務的郵箱
set smtp=smtps://smtp.126.com:465
set [email protected]
set smtp-auth-password=xxxxxx #郵箱的授權碼
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs #證書所在目錄
三:安裝完成後發送可能會失敗,這個時候需要以下命令解決問題
cd /root/.certs/
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 126.crt
echo "zabbix" | mail -s "test" [email protected]
騰訊QQ郵箱證書安裝
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
下面的配置和上面的一樣