centos mailx发送html邮件,centos使用mailx发送邮件

首先请求数字证书

[email protected] ~]# mkdir -p /root/.certs/                           ####创建目录,用来存放证书

[[email protected] ~]# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p‘ > ~/.certs/163.crt ####向163请求证书

depth=2 C = US,O = GeoTrust Inc.,CN = GeoTrust Global CA

verify return:1

depth=1 C = US,CN = GeoTrust SSL CA - G3

verify return:1

depth=0 C = CN,ST = Zhejiang,L = Hangzhou,O = "NetEase (Hangzhou) Network Co.,Ltd",OU = MAIL Dept.,CN = *.163.com

verify return:1

DONE

[[email protected] ~]# certutil -A -n "GeoTrust SSL CA" -t "C," -d ~/.certs -i ~/.certs/163.crt                  ####添加一个证书到证书数据库中

[[email protected] ~]# certutil -A -n "GeoTrust Global CA" -t "C," -d ~/.certs -i ~/.certs/163.crt               ####添加一个证书到证书数据库中

[[email protected] ~]# certutil -L -d /root/.certs                                                                                         ####列出目录下证书

Certificate Nickname Trust Attributes

SSL,S/MIME,JAR/XPI

GeoTrust SSL CA

然后前往163邮箱打开smtp并获取客户端授权码

网页正上方:设置→POP3/SMTP/IMAP

530361e642ea686abc3a817b54f3165b.png

网页左侧:客户端授权密码

114aa60f5d2ce0dbc686b59e3ffee59d.png

最后配置/etc/mail.rc

set bsdcompat

set [email protected]

set smtp=smtps://smtp.163.com:465

set [email protected]

set smtp-auth-password=*********

set smtp-auth=login

set ssl-verify=ignore

set nss-config-dir=/root/.certs

现在发送测试邮件

echo "zabbix test mail" | mail -s "zabbix"

[email protected]

20190416121326902343.png

看起来已经成功了,但是发送完邮件还有报错:证书不被信任,且命令行就此卡住,需要按键才能出现命令提示符

Error in certificate: Peer‘s certificate issuer is not recognized.

于是

[[email protected] ~]# cd /root/.certs/

[[email protected] .certs]# ll

total 80

-rw-r--r-- 1 root root 1793 Jul 6 14:36 163.crt

-rw------- 1 root root 65536 Jul 6 14:37 cert8.db

-rw------- 1 root root 16384 Jul 6 14:37 key3.db

-rw------- 1 root root 16384 Jul 6 14:37 secmod.db

[[email protected] .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.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值