-1

我在 Mac 上使用 Ampps 并尝试使用 php 从联系表单发送电子邮件,但是我没有收到邮件,当提交表单时,它会将我重定向到文件页面,导致显示空白

我的表格:

<form action="email.php" method="post">
                <div class="col-md-6 w3_agileits_contact_left">
                    <span class="input input--akira">
                        <input class="input__field input__field--akira" type="text" id="input-22" name="Name" placeholder="" required="" />
                        <label class="input__label input__label--akira" for="input-22">
                            <span class="input__label-content input__label-content--akira">Your name</span>
                        </label>
                    </span>
                    <span class="input input--akira">
                        <input class="input__field input__field--akira" type="email" id="input-23" name="Email" placeholder="" required="" />
                        <label class="input__label input__label--akira" for="input-23">
                            <span class="input__label-content input__label-content--akira">Your email</span>
                        </label>
                    </span>
                    <span class="input input--akira">
                        <input class="input__field input__field--akira" type="text" id="input-24" name="Subject" placeholder="" required="" />
                        <label class="input__label input__label--akira" for="input-24">
                            <span class="input__label-content input__label-content--akira">Your subject</span>
                        </label>
                    </span>
                </div>
                <div class="col-md-6 w3_agileits_contact_right">
                    <div class="w3_agileits_contact_right1">
                                                <textarea name="Message" id="Message" placeholder="Your comment here..." required=""></textarea>
                    </div>
                    <div class="w3_agileits_contact_right2">
                                                <input type="submit" value="Send">
                    </div>
                    <div class="clearfix"> </div>
                </div>
                <div class="clearfix"> </div>




            </form>

我的文件:

$email = $_POST['Email'];
                                    $name = $_POST['Name'];
                                    $to = "lucvanrooyen@gmail.com";
                                    $subject = $_POST['Subject'];
                                    $userMessage =$_POST['Message'];
                                    $headers = "From: $email\n";
                                    $message = "$name has sent you the following message.\n

                                    Message: $userMessage";
                                    $user = "$email";
                                    $usersubject = "Thank You";
                                    $userheaders = "From: lucvanrooyen@gmail.com\n";
                                    $usermessage = "Thank you for your enquiry we will be in touch.";
                                     mail($to,$subject,$message,$headers);
                                     mail($user,$usersubject,$usermessage,$userheaders);
4

2 回答 2

-1

请检查您的表单标签。表单没有开始标签

<form action="email.php" method="post">
于 2018-03-16T16:14:17.887 回答
-1

您显示的代码不足以调试您的问题。

如果您使用的是标准库中内置的邮件方法,请阅读此答案以了解您可以遵循的一些故障排除步骤。

如果您现在并且仍然觉得它难以使用,那么您可以考虑使用其中一种 PHP 电子邮件解决方案,例如 -

于 2018-03-16T16:03:55.297 回答