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

2018-12-28  本文已影响39人  迷藏_

先安装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

上一篇下一篇

猜你喜欢

热点阅读