POP3/SMTP服务默认是开启的,没开启的点开启
然后点击生成授权码,发送消息,就会给出授权码了
yum install mailx # centos sudo apt-get install heirloom-mailx # ubuntu
编辑配置文件
vi /etc/mail.rc
添加如下内容
set from=**4306@qq.com # 对方收到邮件时显示的发件人 set smtp=smtps://smtp.qq.com:465 # 第三方发邮件的smtp服务器地址 set smtp-auth-user=xx4306@qq.com # 第三方发邮件的用户名 set smtp-auth-password=************ # 授权码 set ssl-verify=ignore set nss-config-dir=/root/.certs set smtp-auth=login # SMTP的认证方式
运行以下命令生成一个证书
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
使用上面的配置,邮件是完全能够发出去的,但是发送邮件的时候会提示 “Error in certificate: Peer’s certificate issuer is not recognized.”提示,运行以下命令即可。
cd /root/.certs/ ll certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
测试
echo "测试邮件" | mail -s "测试" 83xx@qq.com
参考:https://blog.csdn.net/weixin_44044111/article/details/110633188