【发布时间】:2013-05-22 18:42:06
【问题描述】:
我无法调查在我的服务器上尝试执行 AJAX 请求(我正在执行“PUT”/“GET”)时遇到的 500 Internal Server Error。
在本地它运行没有任何问题并且它响应,但是在我将内容上传到服务器后它没有,好像文件/文件夹不存在一样。
自从我上次检查以来,host 在 Apache 上运行,PHP 版本至少为 5.3.0。我在尝试使用页脚时事通讯订阅时收到错误消息。
执行 AJAX 时请求的索引文件如下所示:
<?php
/*
* Import PHPMailer Class
*/
require("phpmailer/class.phpmailer.php");
/*
* Decode JSON Data
*/
$request = json_decode(file_get_contents("php://input"), true);
/*
* Check Valid Email Address
*/
if (!filter_var($request["Email"], FILTER_VALIDATE_EMAIL)) {
echo json_encode([
"error" => true,
"message"=> "You must enter a valid email address"
]);
return false;
};
/*
* Instantiate PHPMailer Class
*/
$mailer = new PHPMailer();
/*
* Set Reply Settings
*/
$reply_email = "no-reply@barbershoppen.dk";
$reply_name = "Barber Shoppen";
/*
* Specific PHPMailer Settings
*/
$mailer->IsSMTP(); /* SMTP Usage */
$mailer->SMTPAuth = true; /* SMTP Authentication */
$mailer->SMTPSecure = "ssl"; /* Sets Servier Prefix */
$mailer->Host = "smtp.gmail.com"; /* SMTP Server */
$mailer->Port = 465; /* SMTP Port */
$mailer->Username = "rolandeveloper@gmail.com"; /* SMTP Account Username */
$mailer->Password = "333333333"; /* SMTP Account Password */
/*
* Email Settings
*/
$mailer->SetFrom($reply_email, $reply_name);
$mailer->AddReplyTo($reply_email, $reply_name);
$mailer->AddAddress($request["Email"]);
$mailer->Subject = "Barber Shoppen [ Confirmation Email ]";
$mailer->Body = "You have successfully subscribed to our newsletter";
$mailer->isHTML(true);
/*
* Send Email
*/
if($mailer->Send()) {
echo json_encode([
"error" => false,
"message"=> "You have successfully subscribed"
]);
} else {
echo json_encode([
"error" => true,
"message"=> $mailer->ErrorInfo
]);
};
?>
我将不胜感激一些帮助或一些指示,我应该朝哪个方向前进并修复此错误。
【问题讨论】:
-
您不只是在这里发布您的 gmail 帐户数据吗?希望在您编辑问题之前,坏人不会窃取您的帐户...
-
服务器日志有错误吗? “500 Internal Server Error”表示存在。
-
我想您现在知道内部错误是因为将错误报告设置为关闭。所以请运行
ini_set('error_reporting','on');来查看确切的错误。 -
是的......这是一个开发帐户......很多人都有它,但我还是删除了通行证:)
-
查看apache错误日志:
tail /var/log/apache2/error.log