菜鸟程序员

centos7.5 mail发送邮件配置

2019-11-21  本文已影响0人  Freeasthew_a098

参考文章:https://blog.csdn.net/djhsun/article/details/78731683

1.安装sendmail mailx

2.获取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 -L -d /root/.certs
#切换到证书所在目录
cd /root/.certs/
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu"  -d ./ -i qq.crt

3 配置mail.rc

set from=xxx@host.cn                             #发送方邮件地址
set smtp=smtps://smtp.exmail.qq.com:465          #邮件服务器
set smtp-auth=login                              #验证方式/登录验证
set smtp-auth-user="xxx@hosts.cn"                #发送方用户权限验证
set smtp-auth-password="xxxxxxxxxx"              #发送方验证密钥(非邮箱密码 授权密码)
set ssl-verify=ignore
set nss-config-dir=/root/.certs
#set nss-config-dir=/etc/pki/nssdb

4 重启sendmail 和 服务器
systemctl restart sendmail
reboot
5.测试发送邮件

echo "mail content" | mail -s "title" ding@qq.com

成功

上一篇 下一篇

猜你喜欢

热点阅读