1.安装mailx
yum -y install mailx
2.编辑配置文件
vim /etc/mail.rc 在文件末尾添加
set nss-config-dir=/root/.cert
set ssl-verify=ignore
set smtp="smtps://smtp.qq.com:465" #第二个博客写的地址不对
set smtp-auth=login
set smtp-auth-user="username@email.com"
set smtp-auth-password="qq邮箱授权密码" #(在QQ邮箱 设置-账户- POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务 里寻找)
set from="username@email.com"
3.生成证书
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
4.确认证书
cd /root/.certs
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
5.测试是否成功
echo “test” | mail -s “test” username@email.com |
| 访问量: 次