mailx配置
1.编辑mail的配置文件
cat /etc/mail.rc
set bsdcompat
set from=xxx@qq.com # 发送邮件后显示的邮件发送方
set smtp="smtps://smtp.qq.com:465" # qq smtp邮件服务器
set smtp-auth-user=xxx@qq.com # 你的qq邮箱
set smtp-auth-password=xxx # 你的qq邮箱密码(设置页面加密后的授权码)
set smtp-auth=login # 动作、登录
set ssl-verify=ignore # 忽略ssl验证
set nss-config-dir=/root/.certs # 证书路径
2.添加邮箱证书到本地
yum -y install nss-tools
# 创建证书目录
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 ~/.certs/qq.crt
3.验证
echo "test test test" | mail -s "title-mail" xxx@qq.com