php表单bug。不发送我的电子邮件

时间:2016-08-10 21:11:43

标签: php html email

我试图自己解决这个问题(以及Stockoverflow中的一些网站和问题),但没有成功。

我的问题是我试图让我的表单实际上发送一封电子邮件到那里的指定地址,但它绝对不起作用。知道我的代码在哪里?

这是一块它,你能看到任何错误吗?

谢谢!

<?php 
if(isset($_POST['submit'])){
$to = "email@gmail.com"; // this is my Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];

$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
}
?>

<body id="getademo">
<div class="titlepage">
        <h1 id="introdemo">GET IN TOUCH</h1>
        <p id="mikshahf">We will get back to you soon!</p>
        </div>
    <div id="form1">
        <div id="formform">
            <form>
                    <p>
                        <input name="name" type="text" class="feedback-input" placeholder="Name" id="name" />
                    </p>
                    <p>
                        <input name="email" type="text" class="feedback-input" id="email" placeholder="Email" />
                    </p>
                    <p>
                        <textarea name="message" class="feedback-input" id="comment" placeholder="Message"></textarea>
                    </p>
                    <div class="submit">
                        <input name="submit" type="submit" value="SEND" id="button-blue"/>
                    </div>
                </form>
            </div>
        </div>


</body>

1 个答案:

答案 0 :(得分:2)

正如我在评论中所述;

因此,您需要添加它。

<form>

错误报告不会发出错误信号。它实际上失败了默默地