PHP POST方法,不发送电子邮件

I need some help. I have a contact formulary for a website, but it isnt sending the email, however the message I programmed to tell its working, popa up right.

Heres the HTML

<!doctype html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
<title>Untitled Document</title>
<link href="CSS/Principal.css" rel="stylesheet" type="text/css">
<link href="fonts.css" rel="stylesheet" type="text/css">
</head>

<body>
<header>
</header>
<section class="formulario">
    <form action="contacto.php" method="post">
      <p>
        <label for="nombre">Nombre:</label>
        <input id="nombre" type="text" name="nombre" placeholder="Nombre, Apellido y/o escuela" required="" />
        <label for="email">Email:<br>
        </label>
        <input id="email" type="email" name="email" placeholder="ejemplo@nightjunkies" required="" />
        <label for="mensaje">Mensaje:</label>
        <textarea id="mensaje" name="mensaje" placeholder="Mensaje" required>    </textarea>
        <input id="submit" type="submit" name="submit" value="Enviar" />
      </p>
    </form>

  </section>

</body>
<footer>
<p class="footer">Powered By Xanmaya&copy;
</footer>
</html>

And here`s the PHP used

<?php
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$mensaje = $_POST['mensaje'];
$para = 'villasantdesign@gmail.com';
$titulo = 'ASUNTO DEL MENSAJE';
$header = 'From: ' . $email;
$msjCorreo = "Nombre: $nombre
 E-Mail: $email
 Mensaje:
 $mensaje";

if ($_POST['submit']) {
if (mail($para, $titulo, $msjCorreo, $header)) {
echo "<script language='javascript'>
alert('Mensaje enviado, muchas gracias.');
window.location.href = 'http://nightjunkies.com.mx';
</script>";
} else {
echo 'Falló el envio';
}
}
?>

Ill appreciate some help

Finally I fixed it using PHPMailer instead

<?php
require 'phpmailer/PHPMailerAutoload.php';
if(isset($_POST["submit"] ))
{
    $nombrede = "Administrador";
    $de = 'example@domain.com';
    $nombre = $_POST["nombre"];
    $email = $_POST["email"];
    $mensaje = $_POST["mensaje"];

    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->Host = 'smtp1.example.net';
    $mail->SMTPAuth = true;
    $mail->Username = 'example@mydomain.com';
    $mail->Password = 'password';
    $mail->Port = 80;

    $mail->From = $email;
    $mail->FromName = $nombre;
    $mail->addAddress($de, $nombrede);

    $mail->Subject = "Contacto Night Junkies";
    $mail->Body = $mensaje;

    if($mail->Send())
    {
        echo "<script language='javascript'>
alert('Mensaje enviado, muchas gracias.');
window.location.href = 'http://nightjunkies.com.mx';
</script>";
    } else {
        echo 'Hubo un problema';
        echo 'Mailer Error: ' . $mail->ErrorInfo;


}
}
?>

There are a lot of reasons this might not work. How is PHP configured to handle mail()? Does that work from the server? You're also likely raising SPAM flags or simply being blocked. A better way to send reliable email is to setup an SMTP account and send the mail from that authenticated account. PHPMailer may help speed things up for you.

It's not working because you are trying to send the email from the receivers email. you can do this.

replace $header = 'From: ' . $email;

with $header = 'From: ' . $para;

and see if that helps you.

This maybe you run it in localhost or local server. try online and add this lines:

$headers .= "Cc: VALID@EMAIL.COM
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";

Besides, you should type valid email as a SENDER, as in your code:

$header = 'From: ' . $email;

UPDATED 2:

<?php
$email_reciever='reciever@emailvalid.com'; // user's email that fills the form

$to = $email_reciever;
$subject = 'ASUNTO DEL MENSAJE';
$headers = "From: NightJunkies <sender@validemail.com>
";
$headers .= "Cc: sender@validemail.com
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$message = '<html><body>';
$message = 'Hello, friend!';
$message .= "</body></html>";
mail($to, $subject, $message, $headers);
echo "<script>alert('Mensaje enviado, muchas gracias!');</script>";
echo "<meta http-equiv='refresh' content='0; url=http://nightjunkies.com.mx'>";
?>

if it is not valid sender email, receiver's server will ignore it even not receive it. dont forget to see in junk or spam folder

Check also here for mail format