首页 > 技术文章 > jumpservice使用465端口发送邮件

ling-yu-amen 2019-04-24 15:23 原文

阿里云、华为云等云服务器默认屏蔽掉了25端口后,内网服务器如何通过跳板机发送邮件到外网邮箱。

如果是可联网的阿里云机器,可以直接配置mailx使用465端口发送邮件。需要进行ssl验证配置。

CentOS7云主机,通过mail命令发,使用465端口(smtps协议)发送邮件
#创建证书
mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/126.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt
certutil -L -d /root/.certs
#信任证书
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 126.crt

# 配置/etc/mail.rc 邮件服务配置文件

vim /etc/mail.rc

再最后添加:

set smtp="smtps://smtp.126.com:465"
set smtp-auth=login
set smtp-auth-user="********@126.com"      #换成你的126邮箱
set smtp-auth-password="*********" #       换成你的126邮箱第三方登录密码
set ssl-verify=ignore
#set nss-config-dir=/etc/pki/nssdb
set nss-config-dir=/root/.certs

说明:
#smtp-auth-password的密码是126邮箱里面设置的第三方登录密码,不是你126的密码,在126邮箱设置界面配置

测试:

echo message3 | mail -v -r "********@126.com" -s "hello world" *********@qq.com
注意:一定要带-r参数,生产上去掉-v参数

 

 

推荐阅读