mailx 使用ssl邮件发送配置 2018-12-28

先安装mailx
yum install mailx
编辑配置文件
vim /etc/mail.rc
追加以下内容

set [email protected]
set smtp=smtps://smtp.qq.com:465                                              
set [email protected]
set smtp-auth-password=**************
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set [email protected] 发送邮箱
set smtp=smtps://smtp.qq.com:465 发件服务器
set [email protected] 发件用户名
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 "邮件主题" [email protected]

你可能感兴趣的:(mailx 使用ssl邮件发送配置 2018-12-28)