PHP Email Form不安装PostFix发送邮件

时间:2013-12-17 20:18:52

标签: php ubuntu-12.04

我在我的网站www.waldoswall.com上有一个非常基本的电子邮件表格,我正在建立一个投资组合。我在收到邮件表单以将邮件发送到我的电子邮件地址时遇到问题。我找到了一个教程并按照此处的说明安装了PostFix:https://www.digitalocean.com/community/articles/how-to-install-and-setup-postfix-on-ubuntu-12-04

我不确定这是否是我如何设置服务器的问题(我从rackspace托管并尝试根据教程和我的个人知识自行设置所有内容。)或者我的php代码存在问题。我已经阅读了一些我应该检查php日志的地方,我很困惑,我可能会在服务器上找到这个文件,仔细看看。现在我会发布我的代码,以防出现明显错误。

    <form method="POST" action="verify.php">
        <div id="formContent">
        <div id="formLeft">
        <h3>Name:</h3><br /><input class="whitebg" name="name" type="text"><br /><br />
        <h3>Email:</h3><br /><input class="whitebg" name="email" type="email"><br /><br />
        <h3>Phone:</h3><br /><input class="whitebg" name="tel" type="tel"><br /><br />

        </div>
        <div id="formRight">
            <div style="clear:both;"><h3>Message:</h3><br /><textarea class="whitebg" cols="50" name="message"></textarea><br /><br /></div>


        </div>

        </div>
        <div id="formBottom">
        <?php
        require_once('recaptchalib.php');
        $publickey = "6LegNOkSAAAAADFzJsNJtYMJc8bpDMMPY9pm4lBb"; // you got this from the signup page
        echo recaptcha_get_html($publickey);
        ?>
        <p><input style="margin-top:25px;" class="whitebg" type="submit" value="Submit"></p>
        </div>
    </form>

验证php文件包含以下代码:

<!DOCTYPE HTML>
<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<title>Home - Kevin Waldmann</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<div id="topSpace"><h1>Waldos Wall</h1></div>
<div style="padding:25px;" class="contentPane" id="slideVerify">
        <div id="goHomeBg">
        <div class="navItem unselectable" id="goHome" onclick="window.location = 'http://www.waldoswall.com';">Go Home</div>        
 <?php
require_once('recaptchalib.php');
$privatekey = "6LegNOkSAAAAACO0vWlqLWRZTkkpntcAM3IHHiaw";
$resp = recaptcha_check_answer ($privatekey,
                          $_SERVER["REMOTE_ADDR"],
                          $_POST["recaptcha_challenge_field"],
                          $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
  // What happens when the CAPTCHA was entered incorrectly
  die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
   "(reCAPTCHA said: " . $resp->error . ")");
} else {
  // Your code here to handle a successful verification
$to = "kjwaldmann@gmail.com";
$subject = "Waldos Wall Contact Form";
$message = "Hello Kevin!<br/>" . "Name:" . $_REQUEST["name"]. "\r\n" . "Email:" .$_REQUEST["email"] . "\r\n" . "Telephone:" . $_REQUEST["tel"] . "\r\n" . "Message:" .$_REQUEST["message"];
$from = $_REQUEST["email"];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Message Sent.";
}
?>

</div>
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:0)

认真建议使用Pear's Net_SMTP邮件,我在我的服务器上使用它,它就像一个魅力!!

另外,如果您不想使用它...将$ _REQUEST更改为$ _POST,因为它已知更好。

答案 1 :(得分:0)

我知道你没有看到任何错误吗?

我先检查一下日志。继续尝试直接从您的ssh控制台发送电子邮件,并检查/ var / log /

中的邮件日志

如果发布任何错误