天天看点

Centos 7下如何配置SMTP SSL(邮箱发送功能)

1.安装openssl

yum install -y openssl openssl-devel

2.安装mailx

yum -y install mailx

3.启用SSL功能

mkdir -p /root/.certs/
cd $HOME
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.配置mail.rc文件

vim /etc/mail.rc

在mail.rc文件末尾增加如下内容(腾讯云企业邮箱群组账号和密码)

Centos 7下如何配置SMTP SSL(邮箱发送功能)
set from=
set smtp=smtps://smtp.exmail.qq.com:465
set smtp-auth-user=
set smtp-auth-password=
set smtp-auth=login

set ssl-verify=ignore
set nss-config-dir=/root/.certs
           

5.测试验证

echo "hello,world" |mailx -v -s "test from huanwei" [email protected]

Centos 7下如何配置SMTP SSL(邮箱发送功能)

如上截图表示测试邮件发送成功

6.查收邮件

继续阅读