centos7使用mailx通过阿里云企业邮箱465端口发送邮件

目的是为了 前几篇,如果发现部署分支是生产分支,并且没有提交记录或者当日的提交,就通知运维检查.

 

 

请求数字证书

mkdir -p /root/.certs/

echo -n | openssl s_client -connect smtp.mxhichina.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/ali.crt

添加证书到证书数据库中

certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/ali.crt

certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/ali.crt

列出目录下证书

certutil -L -d /root/.certs

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

 

 

yum -y install mailx

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

 

 

将/etc/mail.rc修改为下面格式

set [email protected]

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

set [email protected]

set smtp-auth-password=password

set smtp-auth=login

set ssl-verify=ignore

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

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

 

执行

cd /root/.certs/

certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i ali.crt

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

有这个提示,说明SSL证书配置生成及安装完成 。不执行会导致发送提示证书不被信任,但是仍可以发送.

 

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

发送邮件

echo "jenkins test mail" | mail -s "jenkins"  [email protected]

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

这里服务器时区需要+8小时计算

centos7使用mailx通过阿里云企业邮箱465端口发送邮件

 

 

如果发送失败 检查文件夹权限和文件权限并根据报错查看

 

http://dy.163.com/v2/article/detail/DV56MMN00525C3HA.html

https://www.cnblogs.com/yunweis/p/8149242.html