简体   繁体   English

PHP电子邮件表单未发送安装了PostFix的邮件

[英]PHP Email Form not sending mail with PostFix installed

I have a very basic email form on my website, www.waldoswall.com that I am building as a portfolio piece. 我的网站www.waldoswall.com上有一个非常基本的电子邮件表单,我将其作为投资组合。 I am having issues getting the mail form to send mail to my email address. 我在获取邮件表格以将邮件发送到我的电子邮件地址时遇到问题。 I found a tutorial and installed PostFix as per the instructions here: https://www.digitalocean.com/community/articles/how-to-install-and-setup-postfix-on-ubuntu-12-04 我找到了一个教程并按照此处的说明安装了PostFix: https//www.digitalocean.com/community/articles/how-to-install-and-setup-postfix-on-ubuntu-12-04

I am not certain if it is an issue with how I set up the server (I host from rackspace and try to set up everything myself based on tutorials and my personal knowledge.) or a problem with my php code. 我不确定这与我如何设置服务器有关(我是从机架空间托管并根据教程和我的个人知识尝试自行设置所有内容的)还是我的php代码有问题。 I have read a few places that I should check the php log and am confused as to where I might find this file on the server to take a closer look. 我已经阅读了一些应该检查php日志的地方,并对我可能在服务器上找到此文件的位置感到困惑。 For now I'll post my code in case something is obviously wrong. 现在,我将发布代码,以防万一出现明显错误。

    <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>

The verify php file contains the following code: 验证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>

I seriously recommend using Pear's Net_SMTP for mail, I use it on my server and it works like a charm!! 严重建议使用Pear的Net_SMTP进行邮件,我在服务器上使用它,它的作用就像是一种魅力!!

Also, if you don't want to use that... change $_REQUEST to $_POST as it is known to be better. 另外,如果您不想使用该选项,则将$ _REQUEST更改为$ _POST,因为它会更好。

I get that you're not seeing any errors are you? 我知道您没有看到任何错误,是吗?

I'd check the logs first. 我先检查一下日志。 Go ahead and try to send an email right from your ssh console and check your mail logs in /var/log/ 继续尝试从ssh控制台直接发送电子邮件,并检查/ var / log /中的邮件日志

If there are any errors post them 如果有任何错误发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM