请求数字证书
mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.mxhichina.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/ali.crt
添加证书到证书数据库中
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/ali.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/ali.crt
列出目录下证书
certutil -L -d /root/.certs
yum -y install mailx
将/etc/mail.rc修改为下面格式
set from=test@ccc.com
set smtp=smtps://smtp.mxhichina.com:465
set smtp-auth-user=test@ccc.com
set smtp-auth-password=password(授权密码)
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 ali.crt
有这个提示,说明SSL证书配置生成及安装完成 。不执行会导致发送提示证书不被信任,但是仍可以发送.
发送邮件
echo “zabbix test mail” | mail -s “zabbix” cc_test@abc.com
如果发送失败 检查文件夹权限和文件权限并根据报错查看