无法使用 msmtp 通过 php 发送邮件

无法使用 msmtp 通过 php 发送邮件

我希望服务器能够通过 gmail smtp 发送邮件。msmtp 安装成功。我能够通过命令行使用 msmtp 发送。但是,当我尝试通过 php 发送时,出现了此错误。

postfix/smtp[11241]: 连接到 gmail-smtp-in.l.google.com[74.125.200.27]:25: 连接超时

postfix/smtp[11241]: 连接到 gmail-smtp-in.l.google.com[2404:6800:4003:c00::1b]:25: 网络无法连接连接到 alt2.gmail-smtp-in.l.google.com[74.125.25.26]:25: 连接超时

postfix/smtp[11241]: 8F4DB10D10: to=, reply=none, delay=1086, delays=993/0.13/93/0, dsn=4.4.1, status=deferred (连接到 alt2.gmail-smtp-in.l.google.com[74.125.25.26]:25: 连接超时)

我已经更改了 postfix 配置文件

inet_interfaces = localhost

inet_interfaces = all

但仍然无济于事

知道为什么吗?

顺便说一下,我正在使用带有 LEMP 堆栈的 Centos。

答案1

我发现问题了,原来是msmtp配置文件权限问题。我将其更改为正确的用户和组,现在就可以正常工作了。

答案2

如果您从 gmail 发送电子邮件,即您的 gmail 帐户并明确使用 postfix,您将需要 sasl auth 并在端口 587 上使用 Google 的 smtp 连接...Postfix-Gmail 指南

相关内容