gpt4 book ai didi

php - Swiftmailer:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110]

转载 作者:IT王子 更新时间:2023-10-29 00:12:09 25 4
gpt4 key购买 nike

我发帖是因为我已经完成了此处其他问题中发布的解决方案,但它们没有帮助。

我想做的是通过 Google Apps for Business Gmail 使用 Swiftmailer 发送电子邮件,但我一直收到此错误:

Connection could not be established with host smtp.gmail.com [Connection timed out #110]

我知道代码没问题,因为它可以在我的本地机器上运行,但不能在生产服务器上运行。

到目前为止我尝试了什么:

  • 启用 OpenSSL。
  • 从 Google 验证码中解锁帐户。
  • 使用了应用专用密码。
  • 列入白名单的 Gmail SMTP IP 地址

配置:

# Swiftmailer Configuration
swiftmailer:
transport: smtp
encryption: ssl
auth_mode: login
host: smtp.gmail.com
username: contact@mydomain.com
password: applicationspecificpassword
port: 465

我还能尝试什么?这可能是 DNS 问题,因为我使用的是 Gmails SMTP MX 记录而不是服务器。

最佳答案

以下步骤对我有用:

  1. 检查 httpd_can_sendmail 是否打开,运行此 getsebool httpd_can_sendmail

    • 当您得到:httpd_can_sendmail --> off 时,运行 setsebool -P httpd_can_sendmail 1
    • 当您获得:httpd_can_sendmail --> 开启时,这是第 2 步的正确步骤。
  2. 同时检查 httpd_can_network_connect 是否打开,运行 getsebool httpd_can_network_connect

    • 当您httpd_can_network_connect -->关闭时运行setsebool -P httpd_can_network_connect 1
    • 当您获得:httpd_can_network_connect --> 开启时,这是第 3 步的正确步骤。
  3. smtp 使用以下设置:'host' => '64.233.166.108''端口' => '465'

我用的是Centos

关于php - Swiftmailer:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25517281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com