Sp我正试图发送一封电子邮件,代码工作正常,直到我从标准电子邮件切换到html电子邮件。
这是现场直播:http://kenthomes.net/Amelia-Cove
点击"共享此计划"。
我的代码是: $person = $_POST["name"];
//Where will you be pulling emails from?
$emailDB = "emailAddresses";
$type = $_POST["type"];
//Get Share URL that is misformatted.
$waybefore = $_GET["share"];
$before = str_replace("*", "?", $waybefore);
$shareMe = str_replace("!", "=", $before);
$id = $_SERVER['HTTP_REFERER'];
$id = $_SERVER['HTTP_REFERER'];
//Where do you want a copy of this email to go to? (or null)
$copyDB = "";
if($_GET["com"])
{
$prettyType = "Community";
}
else if($_GET["inv"])
{
$prettyType = "Move-In Ready Home";
}
else if($_GET["mod"])
{
$prettyType = "Model Home";
}
$_POST["date"] = date("Y-m-d");
$Emails = new Controller($emailDB, null, null, true);
$ed = $Emails->getData();
//
// The good stuff
//
$emailTo = $_POST["email"];
$subject = "Kent Homes - " . $person . " would like to share a " . ucwords(strtolower($_GET['type'])) . " with you!";
$out = '<html><body>';
$out .= $person . " thought you would like this " . $prettyType . " by Kent Homes. Click the link to view: http://kenthomes.net" . $shareMe . "</br></br>";
$out .= "Additional Message from " . $person . "</br>";
$out .= $_POST['msg'];
$out .= '</body></html>';
$headers = "From: " . $person "<noreply@kenthomes.com>'r'n";
$headers .= "Reply-To: <noreply@kenthomes.com'r'n";
$headers .= "X-Mailer: PHP/" . phpversion()."'r'n";
$headers .= "MIME-Version: 1.0'r'n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1'r'n";
//
// Send 'er off!
//
mail($emailTo, $subject, $out, $headers);
if($toEmail) {
mail($emailTo, $subject, $out, $headers);
}
echo "<p>This " . ucwords(strtolower($_GET['type'])) . " has been sent to " . $_POST["email"] . ".</p>";
unset($_POST["id"]);
我得到错误:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
这是在html邮件之前的功能代码:
$Captcha = new MCaptcha();
if($_POST["submitit"])
{
$answer = $Captcha->checkAnswer();
if($answer)
{
$person = $_POST["name"];
$emailTo = $_POST["email"];
$subject = "Kent Homes - " . $person . " would like to share a " . ucwords(strtolower($_GET['type'])) . " with you!";
//Where will you be pulling emails from?
$emailDB = "emailAddresses";
$type = $_POST["type"];
//Get Share URL that is misformatted.
$waybefore = $_GET["share"];
$before = str_replace("*", "?", $waybefore);
$shareMe = str_replace("!", "=", $before);
$id = $_SERVER['HTTP_REFERER'];
$id = $_SERVER['HTTP_REFERER'];
//Where do you want a copy of this email to go to? (or null)
$copyDB = "";
if($_GET["com"])
{
$prettyType = "Community";
}
else if($_GET["inv"])
{
$prettyType = "Move-In Ready Home";
}
else if($_GET["mod"])
{
$prettyType = "Model Home";
}
$out = $person . " thought you would like this " . $prettyType . " by Kent Homes. Click the link to view: http://kenthomes.net" . $shareMe . " ";
$_POST["date"] = date("Y-m-d");
$Emails = new Controller($emailDB, null, null, true);
$ed = $Emails->getData();
mail($emailTo, $subject, $out, $headers);
if($toEmail) {
mail($emailTo, $subject, $out, $headers);
}
echo "<p>This " . ucwords(strtolower($_GET['type'])) . " has been sent to " . $_POST["email"] . ".</p>";
unset($_POST["id"]);
}
}
我没有看到任何会导致500的代码问题。不可见的项可能导致500:
- 是否包含并定义了"控制器"?
- 在控制器的构造中是否发生了任何会导致500的事情?
- 在你删除的代码中有语法错误吗?
首先,我会检查您的apache日志。在Ubuntu中,它们通常在/var/log/apache2/error.log中。如果错误日志中没有打印任何内容,则可能是内存或时间不足。我对此表示怀疑,但如果是的话,那么这些将会有所帮助:
报错(' memory_limit ', ' 1 g ');
set_time_limit (3600);它们将帮助您进行诊断,但是您需要为您的用例配置您的运行时。
如果你的错误日志中打印了一些东西,调查一下——这可能就是问题所在。
如果这些都没有帮助,试着在剧本中间死去,看看它能走多远。当你到达错误的代码段时,它会自动死亡,而不会打印出死亡消息。
死亡("是");
语法错误:
$out .= "Additional Message from " $person . "</br>";
应该是:
$out .= "Additional Message from " . $person . "</br>";