Can someone please correct this simple php script I am using for my mailform.
It has worked fine on my previous server. On my new server I am still getting the mail however the message txt does not show up in my mail.
Your code… well I’m not sure what it’s doing. Looks like the $to is fine. The $msg … I don’t see that defined anywhere. If that’s the message, it’s in the wrong spot. You need the subject of the email before the message.
Your Code:
<?PHP
$to = "me@hotmail.com";
$messsage = "$name
";
$messsage = "$message
";
mail($to, $msg, "From: My web site
Reply-To: $email
");
echo "passed";
?>
Try:
<?PHP
$to = "me@hotmail.com";
$messsage = "$name
";
$messsage = "$message
";
$headers = 'From: My web site' . "
" . 'Reply-To: ' . $email;
if(mail($to, "Put in a subject", $message, $headers)){
echo "passed";
}else{
echo "failed";
}
?>
You may want to check the PHP in that since I did it off the top of my head. It may need to be tweaked a bit.
Ankou THx so much for taking the time to rewrite the script. I tried it on my server but am still getting the same results. I have tried to tweak some things myself but am having no luck probably do to the fact that I have no knowledge of PHP whatsoever.
If someone can spot the error it would be fantastic
<?PHP
$to = "me@hotmail.com";
$messsage = "$name
";
$messsage = "$message
";
$headers = 'From: My web site' . "
" . 'Reply-To: ' . $email;
if(mail($to, "Put in a subject", $message, $headers)){
echo "passed";
}else{
echo "failed";
}
?>
I see…
Above is the code I put… there’s a few things that need changing. I didn’t notice that you had:
$messsage = "$name
";
$messsage = "$message
";
Notice that it’s $messsage – there’s an extra ‘s’ in there. And the second $messsage = "$message
"; should have a .=
I assume you have $messsage because you already had a variable named $message and didn’t want to overwrite it. So you may have added an extra ‘s’ in there to make sure that didn’t happen. Good to do - but bad thing to use a variable name so similar to another one. I changed $messsage to $sendMessage.
Try:
<?PHP
$message = "Test Message";
$name = "Chuck";
$email = "email@noplace.com";
// The above were used just to test the script - you can remove them if needed.
$to = "me@hotmail.com";
$sendMessage = "$name
";
$sendMessage .= "$message
";
$headers = 'From: My web site' . "
" . 'Reply-To: ' . $email;
if(mail($to, "Put in a subject", $sendMessage, $headers)){
echo "passed";
}else{
echo "failed";
}
?>