Centos 7 安装 Mail发送邮件

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tanglin423

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值