最近在阿里云服务器上想通过mailx实现邮件告警,在虚拟机当中可以正常发送,但是云服务器就报了以下这个错误
[root@myserver ~]# could not connect: Network is unreachable
"/root/dead.letter" 11/321
. . . message not sent.
解决方法如下
[root@myserver ~]# mkdir -p /root/.certs/
[root@myserver ~]# echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
depth=2 C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA
verify return:1
depth=1 C = BE, O = GlobalSign nv-sa, CN = GlobalSign Organization Validation CA - SHA256 - G2
verify return:1
depth=0 C = CN, ST = guangdong, L = shenzhen, O = Shenzhen Tencent Computer Systems Company Limited, CN = *.mail.qq.com
verify return:1
DONE
[root@myserver ~]#
[root@myserver ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@myserver ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@myserver ~]# certutil -L -d /root/.certs
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
GeoTrust SSL CA C,,
[root@myserver ~]# echo “邮件内容”|mail -s 标题 12345678@qq.com
[root@myserver ~]# Error in certificate: Peer's certificate issuer has been marked as not trusted by the.
[root@myserver .certs]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
Notice: Trust flag u is set automatically if the private key is present.
[root@myserver ~]# echo “邮件内容”|mail -s 标题 12345678@qq.com