1.准备126或163邮箱账号
2. 安装mail工具
yum install -y mailx
3.配置mail
vi /etc/mail.rc
4.添加以下配置
set [email protected] #发送邮箱 set smtp=smtps://smtp.126.com:465 #发送邮箱的smtp服务器 set [email protected] #发送邮箱 set smtp-auth-password=xxxx #口令 //注意不是密码 这里需授权码 set smtp-auth=login set ssl-verify=ignore set nss-config-dir=/root/.certs #存放证书的目录
5.配置签名证书
echo -n | openssl s_client -connect smtp.126.com:465| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/126.crt certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 126.crt certutil -L -d /root/.certs
6.发送测试邮件
echo '日志内容' | mail -s '系统日志' [email protected]