if (!$_POST['SEND']) {
echo "
Thank you for your interest in Mr. Omelette Caterers. To contact us, please fill out the information below and a catering specialist will contact you shortly.
If you would like to send a quick email note without using this form, please click here.
";
showform();
}
else {
// Check if form was submitted:
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) {
// Build POST request:
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_secret = '6Lc25bUUAAAAAJ7c1-G0LtjO_1Pr-ZDIuqw6R1d8';
$recaptcha_response = $_POST['recaptcha_response'];
// Make and decode POST request:
$recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
$recaptcha = json_decode($recaptcha);
// Take action based on the score returned:
if ($recaptcha->score >= 0.5) {
// Verified - send email
} else {
$recaptacherror = "1";
// Not verified - show form error
}
}
if (!$_POST['name'] || !$_POST['email'] || $recaptacherror == '1' || $_POST['name'] == $_POST['lname']) {
echo "
Sorry,
There was an error in trying to process your email. Please be sure to complete all \"required fields\".
";
showform();
}
else {
sendmail();
}
}
?>
function showform() {
$name = $_POST['name'];
$lname = $_POST['lname'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$phoneext = $_POST['phoneext'];
$fax = $_POST['fax'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$comments = $_POST['comments'];
echo "
";
}
function sendmail() {
$name = $_POST['name'];
$lname = $_POST['lname'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$phoneext = $_POST['phoneext'];
$fax = $_POST['fax'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$comments = $_POST['comments'];
echo "
Thank You for Writing Us!
Your form was submitted to one of our catering specialists. You will be contact shortly.
Thank you for choosing Mr. Omelette Caterers.
";
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mailhost.wwwebtek.com"; // specify main and backup server
$mail->SMTPAuth = false; // turn on SMTP authentication
//$mail->Username = "jswan"; // SMTP username
//$mail->Password = "secret"; // SMTP password
$mail->From = "$email";
$mail->FromName = "$name $lname";
//[email protected]
//$mail->AddAddress("[email protected]", "Mr. Omelette");
$mail->AddAddress("[email protected]", "Mr. Omelette");
$mail->AddAddress("[email protected]", "Mr. Omelette");
//$mail->AddAddress("[email protected]"); // name is optional
$mail->AddReplyTo("$email", "$fname $lname");
$mail->WordWrap = 50; // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Contact Information from Mr. Omelette website";
$mail->Body = "** Contact Information from Mr. Omelette website **
-------------------------------------------------------------------
Name: $name $lname
Company: $company
E-Mail Address: $email
Phone Number: $phone $phoneext
Fax Number: $fax
Address:
$street
$city, $state $zip $country
Comments:
$comments
";
$mail->AltBody = "** Contact Information from Mr. Omelette website **
-------------------------------------------------------------------
Name: $name $lname
Company: $company
E-Mail Address: $email
Phone Number: $phone $phoneext
Fax Number: $fax
Address:
$street
$city, $state $zip $country
Comments:
$comments
";
if(!$mail->Send())
{
echo "Message could not be sent.
";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
}
?>