Don't use print "<meta http-equiv=\"refresh\"...
because during testing, it caused an endless loop while sending multiple copies of the same Email.
Use header('Location: ...');
instead, along with exit;
.
Plus, all your <meta http-equiv=\"refresh\"
have generated a parse error.
Working example (tested with Email successfully received):
<?php
$EmailFrom = "email@mydomain.com";
$EmailTo = "email@mydomain.com";
$Subject = "Contacting Me";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if (!$validationOK) {
// echo "error 1";
header('Location: error.htm');
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
header('Location: http://www.example.com/');
exit;
}
else{
header('Location: error.htm');
exit;
}
?>