Linux Centos 7环境下的mailx代理163邮箱发送邮箱

一、安装mailx
yum -y install mailx

二、配制

[~]# vim /etc/mail.rc
set                            # 发送邮件后显示的邮件发送方
set smtp.163.com                                            # 163 smtp邮件服务器
set        # 你的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 ,

注:echo 的为邮件内容,-s 是邮件主题,-a 为添加附件,逗号分隔多个邮箱地址。

相关推荐