You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用msmtp通过Yahoo邮箱发送邮件时TLS验证失败的问题求助

msmtp通过Yahoo邮箱发送邮件时TLS验证失败的问题求助

我现在正尝试用msmtp通过SMTP协议发送邮件,目标是用Yahoo邮箱账户实现正常发送。目前我已经完成了配置(配置内容放在下方),如果运行时加上--tls-certcheck=off参数,邮件能正常通过我的Yahoo账户发送,但这样显然不安全。

当我去掉这个参数后,根据指定的信任文件路径不同,会遇到两种错误:

  • 当证书放在/etc/ssl/certs目录下时,会报错:

    msmtp: TLS certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.

  • 当证书放在/root目录下时,会报错:

    msmtp: cannot set X509 trust file /root/yahoo.crt for TLS session: Error while reading file.

其实这两个路径下的是同一个证书文件,我从yahoo.com导出证书链后,已经去掉了文件里的^M字符。

我现在有点困惑:证书的文件名会影响验证吗?我已经更新了ca-certificates包,但不确定这么做是否正确。另外我注意到Yahoo的根证书是DigiCert SHA2 High Assurance Server CA,我不确定这个证书是否已经安装在我的系统里,而且我确认证书是正确的X509格式。

想请教一下接下来应该怎么排查解决这个问题?

我的msmtp配置内容如下:
(注:我试过把tls_trust_file分别设置为/root/yahoo.crt和/etc/ssl/certs/yahoo.crt,对应上面两种错误场景)

# Set default values for all following accounts.
defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        ~/.msmtp.log
#tls_certcheck off

account        yahoo
host           smtp.mail.yahoo.com
port           465
tls_starttls   off
from           <username>@yahoo.<tld>
user           <username>
password       <password>

account default: yahoo

备注:内容来源于stack exchange,提问作者Thomas Stokes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 09:25:30