1.关闭其他的邮件工具
service sendmail stop
chkconfig sendmail off
service postfix stop
chkconfig postfix off
2.安装mailx(我在之前已经安装过了,所以这步我没做)
yum install mailx
3.在邮箱中开启smtp,开启后会得到一个授权码,这个授权码就代替了密码(具体操作参考上面提到的最接近成功的教程)
4.请求数字证书(这里用qq邮箱,所以向qq请求证书)
mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i qq.crt
certutil -L -d /root/.certs
注意:执行上述语句的时候会报错,说qq.crt没有可执行权限,具体在哪一步忘记了,遇到了赋予权限就好,我是直接给了可读可写可执行的权限,指令: chmod 777 qq.crt 需要先cd到/root/.certs/ 目录
5.配置/etc/mail.rc
set from=xxxx@qq.com #设置发送邮件方
set smtp=smtps://smtp.qq.com:465 #邮件服务器
set smtp-auth-user=xxxx@qq.com #用户名
set smtp-auth-password=xxxxxxxxxxx #授权码
set smtp-auth=login #默认login
set ssl-verify=ignore #ssl认证方式
set nss-config-dir=/root/.certs #证书所在目录
6.测试发送邮件指令
echo "date
mysql is stop" | mail -s "mysql is stop" xxxx@qq.com
作者:CC-梅
来源:CSDN
原文:https://blog.csdn.net/m0_37673753/article/details/81356298
版权声明:本文为博主原创文章,转载请附上博文链接!
网友评论