0

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"]);
                    }
                }
4

2 回答 2

0

语法错误:

$out .= "Additional Message from " $person . "</br>";

这应该是:

$out .= "Additional Message from " . $person . "</br>";
于 2013-04-18T14:59:23.847 回答
0

我没有看到任何会导致 500 的代码问题。可能导致 500 的未见项目:

  1. 是否包含并定义了“控制器”?
  2. 在构造控制器时会发生什么会导致 500 的情况吗?
  3. 您为制作此代码段而删除的代码中是否存在语法错误?

首先,我会检查您的 apache 日志。在 Ubuntu 中,它们通常位于 /var/log/apache2/error.log 中。如果您的错误日志中没有打印任何内容,则可能是您的内存或时间不足。我怀疑是这种情况,但如果是这样,那么这些将有所帮助:

ini_set('memory_limit', '1G'); 设置时间限制(3600);

它们将帮助您进行诊断,但您想为您的用例配置运行时。

如果您的错误日志中确实打印了某些内容,请进行调查 - 这可能是问题所在。

如果这些都没有帮助,请尝试在脚本中间死去,看看它能走多远。一旦你到达有问题的代码段,它就会自行死亡,而不会打印出死亡消息。

死(“到了这里”);

于 2013-04-18T14:46:11.303 回答