gpt4 book ai didi

php - SMTP 错误 : Could not connect to SMTP host

转载 作者:可可西里 更新时间:2023-10-31 22:06:46 25 4
gpt4 key购买 nike

我有这段代码,在我的本地服务器上一切正常。电子邮件发送没有任何问题。

但是现在我将内容传递给网络服务器,我得到了这个错误...

SMTP Error: Could not connect to SMTP host.

服务器启用了 SSL..正确吗?那么,问题是什么? enter image description here

            $mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "dnteiro"; // GMAIL username
$mail->Password = "xxx"; // GMAIL password

最佳答案

听起来您的虚拟主机正在阻止到 smtp.gmail.com:465 的出站连接。建议:

  1. 验证:如果您可以通过 shell/终端访问您的网络托管服务器,请尝试 telnet 测试以验证它们是否确实阻止了此操作。运行 telnet smtp.gmail.com 465

  2. 联系方式:调用或发送电子邮件给您的托管服务提供商,了解他们为出站中继提供的 SMTP 服务器。确保他们知道您想使用您的 @gmail.com 地址作为发件人/回复地址。

  3. 更新代码:一旦您的主机为您提供了不同的邮件服务器,请更新您的代码并重试。

如果您的 Web 主机根本不允许从其服务器进行出站中继,那么您需要考虑切换主机,如果这是您的应用程序的要求的话。

关于php - SMTP 错误 : Could not connect to SMTP host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6209064/

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