PHP mail()不从联系人表单发送电子邮件

PHP mail()不从联系人表单发送电子邮件,php,html,forms,email,Php,Html,Forms,Email,当我提交联系人表单时,它会运行脚本并重定向回标题,但不会发送电子邮件。我想我的代码中有一些错误,但我不知道在哪里 HTML代码是: <form action="../php/mail.php" method="POST" enctype="multipart/form-data" name="Email Form" class="pure-form pure-form-stacked"> <fieldset>

当我提交联系人表单时,它会运行脚本并重定向回标题,但不会发送电子邮件。我想我的代码中有一些错误,但我不知道在哪里

HTML代码是:

<form action="../php/mail.php" method="POST" enctype="multipart/form-data" name="Email Form" class="pure-form pure-form-stacked">
                <fieldset>

                    <label for="name">Name</label>
                    <input id="name" name="name" type="text" placeholder="Your Name">


                    <label for="email">Email</label>
                    <input id="email" name="email" type="email" placeholder="Your Email">

                    <label for="message">Message</label>
                    <!--<input id="password" type="password" placeholder="Your Password">-->
                    <input id="message" name="message" type="text" placeholder="Your Message">

                    <button type="submit" class="pure-button">Submit</button>
                </fieldset>
            </form>

名称
电子邮件
消息
提交
PHP脚本是:

<?php
$from = $_POST["email"]; // sender
$name = $_POST["name"];
$message = $_POST["message"];
$message = wordwrap($message, 70);
mail("myemail@gmail.com","My Contact Form",$message,"From: $from\n");
header( 'Location: http://www.mywebsite.com');
?>

试试下面的代码,它会起作用的

$to = "myemail@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" ;

mail($to,$subject,$txt,$headers);
header( 'Location: http://www.mywebsite.com');

你的smtp设置正确吗?您是否已发布到正确的url?是否已安装邮件服务器?提供有关服务器配置的更多详细信息当电子邮件成功传递到邮件“代理”时,邮件功能将返回成功状态。它无法检查邮件“代理”是否真的发送了它,或者即使有一个(正确的)安装了它。有人能告诉我为什么我投了反对票吗?