オンラインで見つけたこの簡単なスクリプトがありますが、機能しません。私は何が欠けていますか?
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = $visitor_email;
$email_subject = "New Message";
$email_body = "You have received a new message from $name.\n".
"\n\n $message".
$to = "myemail@domain.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
try{
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');
} catch(Exception $e){
//problem, redirect to sorry page
header('Location: sorry.html');
}
?>
いつもサンキュー ページにリダイレクトされますが、メールが届きません。すべての HTML は正しいです。