【问题标题】:PHPMailer Hangs on SendPHPMailer 挂起发送
【发布时间】:2013-03-19 12:16:53
【问题描述】:

我已经成功地在少数人内部使用的桌面上使用 WAMPSERVER 设置了一个 Web 应用程序,这使用 PHPMailer 到一个内部 SMTP 服务器,没有加密或身份验证,它工作正常。

那个桌面崩溃了,我已经迁移到一个“新”桌面。我有一个 SVN 设置,所以我什至使用了大部分相同的文件和配置。可能重要的一个区别是旧桌面是 64 位,而新桌面是 32 位。这意味着我正在使用不同版本的 WAMPSERVER。

邮件程序只是挂起。我没有收到 PHP 错误或 PHP 超时。我只是从来没有达到我的剧本的结尾。最疯狂的部分是它可以与身份验证、ssl 和 gmail 一起使用。它只是不适用于我需要的额外简单的情况。

这行得通:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.gmail.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$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 for the GMAIL server
$mail->Username   = "myemail@gmail.com";  // GMAIL username
$mail->Password   = "mypassword";            // GMAIL password
$mail->AddAddress('toemail@supersecret.com', 'John Doe');
$mail->SetFrom('something@gmail.com', 'First Last');
$mail->Send();
?>

以前是这样,但现在不是:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.internal.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->Port       = 25;                   // set the SMTP port for the GMAIL server
$mail->AddAddress('myaddress@somewhere.com', 'John Doe');
$mail->SetFrom('someaddress@mightbereal.com', 'First Last');
$mail->Send();
?>

我从调试中得到的唯一东西是

客户端 -> SMTP:EHLO 桌面主机名

页面上没有显示错误,apache 日志中也没有显示任何错误,如果它们没有显示,我通常会在其中得到 PHP 错误。

我可以通过 25 端口从桌面远程登录到主机,甚至可以输入 EHLO 命令并从服务器获得良好的响应。

我不记得以前遇到过这个问题,尽管我可能已经解决过一次。我在这里或 Google 上找不到任何有用的东西。

请帮忙。谢谢。

【问题讨论】:

  • 你能看懂SMTP服务器的日志吗?
  • 我不能。因为我可以连接 telnet,发出挂起的命令,并得到响应,所以我认为这不是问题所在。此外,在我移至另一台计算机上的不同 WAMPSERVER 版本之前,这曾经可以工作。我不是 100% 确定,但我认为它是 64 位 2.4.2 apache,现在是 32 位 2.2.22。 PHP版本应该是一样的。
  • 下一行:你能fsockopen() 连接到 smtp 服务器吗?如果你手动在那里写EHLO 行会得到什么?
  • 我认为您可能正在做某事。我对这些功能不是很熟悉,如果我搞砸了,请告诉我。我做了: $socket=fsockopen('smtp.internal.com',25);回声 fgets($socket); fwrite($socket,'EHLO 桌面主机名');回声 fgets($socket);我在第一个 echo fgets() 行上遇到了超时的 php 错误。
  • 如果我评论该行,它会进入下一个 fgets 和超时,但在 fsockopen 和 fwrite 上似乎没问题。

标签: php apache wamp phpmailer wampserver


【解决方案1】:

劫持帖子说我遇到了同样的问题,但在示例中将端口设置为 465 而没有将 SMTPSecure 设置为“ssl”,默认情况下它设置了 TLS

【讨论】:

  • 将 smtpsecure 设置为 ssl 也为我修复了它,我正在使用 hostgator。
  • 谢谢!通过 zoho 从 localhost 发送也需要此配置。
【解决方案2】:

遗憾的是,这可能永远不会帮助遇到同样问题的其他人,但我只需将端口更改为 465 就可以让一切正常工作。

【讨论】:

  • 哈,这也是我的问题。将其设置为 993,但这是针对 TLS 的。
【解决方案3】:

最终为我的配置找到了解决方案。
只需将 ssl:// 添加到 smtp.google.com
$mail-&gt;Host = 'ssl://smtp.gmail.com';

【讨论】:

  • 感谢 SendGrid 挂在我身上,你摇滚,谢谢
【解决方案4】:

我有同样的问题。在发送方法之后没有任何显示。 我意识到加密是错误的,我确实使用了 SMTPS

$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
// Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted

【讨论】:

    【解决方案5】:

    如果您的服务器托管在 Hostgator(共享主机)中,这就是为我解决的问题:
    $mail-&gt;SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
    (尽管PHPMailer 中的官方示例建议使用ENCRYPTION_STARTTLS)

    【讨论】:

    • 除非他已经设置了ssl,这是ENCRYPTION_SMTPS的值
    猜你喜欢
    • 1970-01-01
    • 2018-08-30
    • 2016-06-27
    • 2013-11-18
    • 1970-01-01
    • 1970-01-01
    • 2018-04-19
    • 1970-01-01
    • 2015-06-04
    相关资源
    最近更新 更多