在CentOS7中使用mailx发送邮件到QQ邮箱
来源:原创 更新时间:2018-09-06 10:59:17 编辑:管理员 浏览:2676
在centos7中,发送邮件可以使用mailx,有关一些命令参考:点击这里传送到命令宝典
增加一些配置项:
set bsdcompat set from=21108858@qq.com set smtp=smtps://smtp.qq.com:465 set smtp-auth-user=21108858@qq.com set smtp-auth-password=dxngrdmrnjiocagg set smtp-auth=login set ssl-verify=ignore set nss-config-dir=/etc/pki/nssdb/
邮箱换成自已的才可以用哦。
因为需要 QQ 邮箱的 SSL 证书,所以我们还需要手动的获取QQ 邮箱的证书保存到本地指定的目录里以备调用和验证,具体命令如下:
mkdir -p /etc/pki/nssdb/ echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/pki/nssdb/qq.crt certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb -i /etc/pki/nssdb/qq.crt certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb -i /etc/pki/nssdb/qq.crt certutil -L -d /etc/pki/nssdb
为了防止出现前文所说的发送邮件警告提示,还需要进入邮箱 SSL 证书存放目录里执行如下命令:
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
返回如下提示即可:
**Notice: Trust flag u is set automatically if the private key is present.**
这是为了信任证书的标记操作。
至此,已经完成了 mailx 结合 QQ 邮箱发送系统邮件的部署了,通过命令行发送测试邮件试试吧:
mailx -s "邮箱测试" xxxx@qq.com < message_file.txt