使用/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" 要发送的邮箱地址ide
在使用以上方式配置后,能够发送邮件可是会提示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.certscode
又给本身挖了个坑,由于我是要经过zabbix来发送邮件,我zabbix-server启动是用的zabbix用户,可是个人nss-config-dir配置的/root下面的目录,zabbix用户没有权限读取,因此死活发不出去邮件!!!!须要把.certs目录移动到其余目录,而且让启动zabbix-server的用户可以读取到!!!!!server