1、安装mailx
yum install mailx -y
2、 配置mail.rc文件
vim /etc/mail.rc
在最后添加以下配置:
# 指定邮箱
set from=xxx@163.com
# 邮箱协议(由于阿里云默认禁用TCP 25端口,我们可以使用465端口)
set smtp=smtps://smtp.163.com:465
# 邮箱账号
set smtp-auth-user=xxx@163.com
# 邮箱授权码,后台里面去授权
set smtp-auth-password=xxxxxxxxxx
# 登陆方式
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs
3、请求数字证书
[root@server-center ~]# mkdir -p /root/.certs/ ###创建目录,用来存放证书
[root@server-center ~]# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt
[root@server-center ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt ###添加一个ssl证书到证书数据库中
[root@server-center ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt ###添加一个Global证书到证书数据库中
[root@server-center ~]# certutil -L -d /root/.certs ###列出目录下的数字证书
4、解决证书不被信任问题
cd /root/.certs/
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 163.crt
出现以下提示,表示 添加成功:
Notice: Trust flag u is set automatically if the private key is present.
5、测试发送邮件功能
echo "hi jack,i am rose" | mail -s "zabbix" xxx@163.com

1684

被折叠的 条评论
为什么被折叠?



