PHPMailer加载一段时间,然后给出500 - 内部服务器错误

Dav*_*key 7 php phpmailer iis-7.5 windows-server-2008-r2

我正在尝试设置一个php页面来自动发送验证邮件.我想使用gmail smtp服务器,我看过的每个地方都建议使用PHPMailer.我安装它并使用以下示例代码:

ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once ("incl\PHPMailer\PHPMailerAutoload.php");

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "myemail@gmail.com";
$mail->Password = "mypassword";
$mail->SetFrom('myemail@gmail.com','Me');
$mail->AddAddress("ToAddress@gmail.com");
$mail->Subject = "Verify your email";
$mail->Body = "Thank you for signing up.  Please verify your email using the link below:";
$mail->IsHTML (true);

if($mail->Send()){
    echo "Success";
}else{
    echo "Error";
}
Run Code Online (Sandbox Code Playgroud)

当尝试通过Firefox访问该页面时,该页面将加载几分钟,然后给出以下错误:

500内部服务器错误.
您正在查找的资源存在问题,无法显示.

服务器是运行IIS 7.5PHP 5.5.8的Windows Server 2008 R2 Standard .我可以毫无问题地访问所有其他页面,但尝试呼叫似乎是超时或其他东西.我知道这是因为我对每一行进行了评论并慢慢添加了一些内容并且是导致该行为的行.$mail->Send()$mail->Send()

我的谷歌能力让我失望,因为我根本无法弄清楚如何使这项工作.关于可能出错的任何想法?

更新

我打开服务器日志然后再次尝试加载页面,但没有新的错误添加到日志中.但是,我注意到今天发生了以下错误System32\LogFiles\httperr1.log

2014-10-27 06:29:21 1.161.23.122 3148 212.83.145.123 80 HTTP/1.0 CONNECT mx2.mail2000.com.tw:25 400 - URL -  
2014-10-27 10:10:12 95.183.244.244 33553 212.83.145.123 80 HTTP/1.1 GET / 400 - Hostname -
2014-10-27 11:25:25 207.38.185.197 51157 212.83.145.123 80 HTTP/1.1 GET /tmUnblock.cgi 400 - Hostname -
2014-10-27 12:46:21 1.168.221.158 7952 212.83.145.123 80 - - - - - Timer_ConnectionIdle -
Run Code Online (Sandbox Code Playgroud)

更新2

我很肯定我的gmail帐户详细信息是正确的,并已测试使用服务器上的Thunderbird从中发送.尝试在没有安全方法的情况下发送时,如此评论中所示,我收到此错误:

MAIL FROM命令失败,550,5.7.3请求的操作中止; 用户未经过身份验证

我的PHP Mailer版本是5.2.9,我现在也尝试了以下内容:

  • \\在文件路径中使用而不是\
    • 没变
  • 包括class.phpmailer.php而不是PHPMailerAutoload.php
    • Fatal error: Class 'SMTP' not found in C:\inetpub\wwwroot\incl\PHPMailer\class.phpmailer.php on line 1195
  • 在端口465上使用ssl
    • SMTP connect() failed
  • 使用端口25通过Hotmail地址发送 $mail->SMTPAuth = false;
    • MAIL FROM command failed,550,5.7.3 Requested action aborted; user not authenticated

更新3

重新加载问题页面后,我检查了事件查看器,并在Windows日志 - >系统中看到了一个新条目:

PHP错误:语法错误,第101行的C:\ PHP\php.ini中的意外BOOL_TRUE

那条线是:

php_flag display_errors on

小智 0

尝试在端口 465 上使用 SSL 加密:

$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
Run Code Online (Sandbox Code Playgroud)