CentOS7.x 通过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/qq.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
certutil -L -d /root/.certs
#信任证书
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu"  -d ./ -i qq.crt 

# 配置/etc/mail.rcE繁忙
set smtp="smtps://smtp.qq.com:465"
set smtp-auth=login
set smtp-auth-user="[email protected]"  #换成你的qq邮箱
set smtp-auth-password="fwmazaxbllqrcajg"  # 换成你的qq邮箱第三方登录密码
set ssl-verify=ignore 
#set nss-config-dir=/etc/pki/nssdb
set nss-config-dir=/root/.certs

说明:
#smtp-auth-password的密码是qq邮箱里面设置的第三方登录密码,不是你qq的密码,在qq邮箱设置界面配置
 
测试:
echo message3 | mail -v -r "[email protected]" -s "hello world" [email protected]
注意:一定要带-r参数,生产上去掉-v参数

转载于:https://www.cnblogs.com/nulige/p/9092105.html

你可能感兴趣的:(CentOS7.x 通过mail命令发,使用465端口(smtps协议)发送邮件)