what's wrong with this code ? php ..?

Walid

New member
Hey .. i'm trying to make a simple php mail script to use it in my templates .. an everything is working fine .. except that i didn't receive the message on my e-mail

here's the demo code if someone could check for me .. thanks in advance




if(isset($_POST['submit'])){

if(trim($_POST['name']) == ''){
$error = true;
}else {
$name = trim($_POST['name']);
}


if(trim($_POST['mail']) == ''){
$error = true;
}else {
$mail = trim($_POST['mail']);
}


if(trim($_POST['message']) == ''){
$error = true;
}elseif(!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['mail']))){
$error = true;
}else {
$message = trim($_POST['message']);
}


// if there are no errors send the message

if(!isset($error)){

$to = "[email protected]"; /////// add your email address here
$body = "Name: $name \n\nEmail: $mail \n\nSubject: $message \n\nMessage:\n $message";
$headers = 'From: Site <'.$to.'>' . "\r\n" . 'Reply-To: ' . $mail;

mail($to, $body, $headers);

$mailSent = true;

}else {
echo "Error Occured!";
}

}
 
Back
Top