centos通过mail发送文件到163邮箱

1.配置163授权

查看163邮箱如何配置授权码

2.配置mail

vim /etc/mail.rc

添加以下内容

set from=xxx@163.com     	       #发件人,把自己的163邮箱账号地址写上去
set smtp=smtps://smtp.163.com:465  #这个配置不用变
set smtp-auth-user=xxx@163.com     #这个是邮箱登录用户,写成自己的邮箱账号
set smtp-auth-password=xxx   	   #授权码(把第一步的授权码拿过来)
set smtp-auth=login  			   #默认login
set nss-config-dir=/root/.certs    #证书存放位置
set ssl-verify=ignore

3.生成密钥

[root@aaa~] mkdir -p /root/.certs/
[root@aaa~] echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt
[root@aaa~] certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
[root@aaa~] certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
[root@aaa~] certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i 163.crt
[root@aaa~] certutil -L -d /root/.certs

4.测试使用

echo "test"| mail -s "测试"  邮箱地址
echo "巡检结果" | mail -s "阿里云服务器" -a /root/utils/log/HostDailyCheck-iZbp177qmn3ey757jvbzayZ-20210117.txt 邮箱地址

-s参数是主题名称
-a参数是作为附件发送到邮箱里面

测试时可能会遇到问题,像下面图中报错
在这里插入图片描述
可以参考链接,去看下
http://help.163.com/09/1224/17/5RAJ4LMH00753VB8.html

5.成功

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值