使用/etc/mail.rc配置发送邮件,想必大部分运维都配置过,这次新搭建了zabbix-server在配置邮件报警的时候,使用之前的配置方式,但是卡在连接到smtp服务器上,在各种排查后最后查到是因为阿里云对25端口不开放,所以这次使用smtps协议也就是465端口来发送邮件
Resolving host smtp.ym.163.com . . . done.
Connecting to 59.111.176.117:smtp . . .Connecting to 59.111.176.117:smtp . . .^C
在/etc/mail.rc增加如下配置:
########################################
set from="xiaoke@51yuyou.com"
set smtp="smtps://smtp.ym.163.com:465"
set smtp-auth-user="xiaoke@51yuyou.com"
set smtp-auth-password="xiaoke-password"
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb
########################################
echo "sometext"|mail -s "my subject" 要发送的邮箱地址
在使用以上方式配置后,可以发送邮件但是会提示Error in certificate: Peer‘s certificate issuer is not recognized.
解决方法:
mkdir /root/.certs
echo -n | openssl s_client -connect smtp.ym.163.com:465| sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p‘ > ~/.certs/163.com.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.com.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.com.crt
certutil -L -d /root/.certs
完成之后将/etc/mail.rc里面的set nss-config-dir=/etc/pki/nssdb修改为/root.certs
原文地址:http://blog.51cto.com/kexiaoke/2122335