关于“联系我们”页面的问题[关闭]

The following is the code for "Contact Us" page. Is this wrong code? When I send messages, do not go to my E-mail ! i want The correct way to write it?

<?php

if(isset($_POST['sendmail'])) {
    $to='a@example.com';
    if (mail($to,$_POST['name'],$_POST['message'])) {
        echo 'is ok';
    } else {
        echo "Error : Not Send Mail";
    }
} else {
    echo 'not ok!!!';
}
?>

Try this:

http://php.net/manual/en/function.mail.php

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "
" .
    'Reply-To: webmaster@example.com' . "
" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

Customized for your example:

<?php
if(isset($_POST['sendmail'])) {
    $to      = 'a@outlook.com';
    $subject = $_POST['name']; // I do not know if this is your email subject
    $message = $_POST['message'];
    $headers = 'From: a@outlook.com' . "
" . // This will appear as to who sent the email
        'Reply-To: a@outlook.com' . "
" . // This will appear as to who to send the replies
        'X-Mailer: PHP/' . phpversion();


    if (mail($to, $subject, $message, $headers)) {
        echo 'is ok';
    } else {
        echo "Error : Not Send Mail";
    }
} else {
    echo 'not ok!!!';
}
?>