一、关闭本机的sendmail服务或者postfix服务
#sendmial
service sendmail stop
chkconfig sendmail off
#postfix
service postfix stop
chkconfig postfix off
二、安装mailx
yum -y install mailx
ln -s /bin/mailx /bin/mail
chown -R zabbix.zabbix /bin/mail
三、安装证书
mkdir -p /etc/pki/nssdb/
cd /etc/pki/nssdb
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/pki/nssdb/qq.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt
certutil -L -d /etc/pki/nssdb/
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
四、配置邮件
(1)获取授权码
安装步骤操作,发送完邮件会生成一个授权码,复制保存稍后使用
(2)配置邮件信息
vim /etc/mail.rc
在文本最后插入
set nss-config-dir=/etc/pki/nssdb/
set smtp-user-starttls
set ssl-verify=ignore
set from=123456@qq.com #使用自己的QQ邮箱,这个是发件箱
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=123456@qq.com #外部smtp服务器认证的用户名,也是QQ邮箱
set smtp-auth-password=授权码
set smtp-auth=login
五、测试
echo test | mail -v -s " test" test@qq.com #此邮箱为收件箱,使用其他邮箱作为收件箱
测试成功
测试失败(这是多半是证书问题)