【发布时间】: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