PHPMailer加载一会儿,然后给出500-内部服务器错误 [英] PHPMailer loads a while, then gives 500 - Internal server error

查看:104
本文介绍了PHPMailer加载一会儿,然后给出500-内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to setup a php page to automatically send a verification email. I would like to use the gmail smtp servers, and everywhere I've looked suggests to use PHPMailer. I installed it and used the following example code:

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";
}

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

When trying to access the page via Firefox, the page will load for a few minutes, then give this error:

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

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

该服务器是运行 IIS 7.5 PHP版本5.5.8 Windows Server 2008 R2 Standard.我可以访问所有其他页面而没有问题,但是尝试调用$mail->Send()似乎超时了.我之所以知道这一点,是因为我评论了每一行,然后慢慢地添加了一些内容,而$mail->Send()是导致该行为的行.

The server is Windows Server 2008 R2 Standard running IIS 7.5 and PHP Version 5.5.8. I can access all other pages without issues, but trying to call $mail->Send() seems to be timing out or something. I know this because I commented every line and slowly added pieces back in and $mail->Send() is the line that causes the behavior.

我在Google上的能力令我失望,因为我简直不知道该如何进行这项工作.有什么想法可能有问题吗?

My Google abilities are failing me here as I simply cannot figure out how to make this work. Any ideas on what might be wrong?

更新

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

I opened the server log then tried loading the page again, but no new errors were added to the log. However, I noticed the following errors from today in 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 -

更新2

我确信我的gmail帐户信息正确无误,并已使用服务器上的Thunderbird测试了从其发送的邮件.尝试在没有安全方法的情况下发送邮件时,如

I am positive that my gmail account details are correct and have tested sending from it using Thunderbird on the server. When trying to sent without secured methods, as suggested in this comment I get this error:

MAIL FROM命令失败,550,5.7.3请求的操作被中止;用户未通过认证

MAIL FROM command failed,550,5.7.3 Requested action aborted; user not authenticated

我的PHP Mailer版本是5.2.9,我现在还尝试了以下操作:

My PHP Mailer version is 5.2.9 and I've now also tried the following:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆