my code is
<?php
// Set Site Email Addresses Here
/* This email must be one set up on your domain for most hosts and is the email to send mail from */
$siteemailtosend="XX";
/* This email is your email to receive the contact form details and can be the same as the one above if required */
$siteemailtoreceive="XX";
// ******************************************************************
// DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING
// ******************************************************************
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No Values Provided!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
$ipaddress = $_SERVER["REMOTE_ADDR"];
// Create the email and send the message
$to = $siteemailtoreceive;
$email_subject = "Website Contact From: $name";
$email_body = "You have received a new message from your website contact form.\n\r\n";
$email_body = $email_body."Here are the details:\n\r\n";
$email_body = $email_body."Name: $name\n\r\n";
$email_body = $email_body."Email: $email_address\n\r\n";
$email_body = $email_body."Phone: $phone\n\r\n";
$email_body = $email_body."Message:\n$message\n\n\r\n";
$email_body = $email_body."Sender's IP Address: $ipaddress\n\r\n";
$headers = "From: $siteemailtosend\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
if ((mail($to,$subject,$message,$headers))&&(mail($autoTo, "Thank You from JDR Excavating", $autoreply, 'From: name@domain.com'))) {
header("Location: ".$goto_after_mail);
$success = "Your message has been sent. A JDR Excavating representative will be in contact with you shortly!";
}
?>