一、安装mailx
yum -y install mailx
二、配制
[[email protected]~]# vim /etc/mail.rc
set [email protected] # 发送邮件后显示的邮件发送方
set smtp.163.com # 163 smtp邮件服务器
set [email protected] # 你的163邮箱
set smtp-auth-password=yourpass # 你的163邮箱密码(设置页面加密后的授权码)
set smtp-auth=login # 动作、登录
set smtp-use-starttls # 安全连接传输
set ssl-verify=ignore # 忽略ssl验证
set nss-config-dir=/root/.certs # 证书路径
三、生成163的证书
mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p‘ > ~/.certs/163.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -L -d /root/.certs
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.
四、测试发送邮件
echo " Redhat7 更换yum 源为Centos7的阿里云yum源"|mailx -s "rpm -e yum redhat" -a Centos7_yum_org_aliyun.tar.gz [email protected],[email protected]
注:echo 的为邮件内容,-s 是邮件主题,-a 为添加附件,逗号分隔多个邮箱地址。
原文地址:https://blog.51cto.com/13396187/2469825
时间: 2024-10-31 11:14:09