<?php

###########################################################################
#
# Simple Form to email script.  Basic Contact form
#
# Copyright 2006 Host45.com, Inc. 
# Web and Email Hosting 
# http://www.host45.com
#
###########################################################################

# Setup Message
$msgBody "Name: {$_POST['name']}\n
Company: {$_POST['company']}\n
Title: {$_POST['title']}\n
Address: {$_POST['address']}\n
Address2: {$_POST['address2']}\n
Phone: {$_POST['phone']}\n
E-mail Address: {$_POST['emailaddress']}\n\n
Comments:\n\n{$_POST['comments']}"
;

# Change to your Email Address and Subject
$ToName "you@yourdomain.com";
$Subject "Contact Form";

# Check for Email Injection Exploit before sending Email
if(strstr($msgBody,"Content-Type:") || strstr($msgBody,"MIME-Version:") || strstr($msgBody,"bcc:") || strstr($msgBody,"Subject:"
   || 
strstr($msgBody,"Content-Transfer-Encoding:") || (!preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i',$_POST['emailaddress']))) {

  
# Spam Exploit Attempt - Redirect or display something here
  #Header("Location: /spammer.php");

} else {

  
# Send the email if valid form submission
  
mail($ToName$Subject$msgBody"From: {$_POST['emailaddress']}");
}

# Redirect to a page of your choice here
Header("Location: /thankyou.php");

?>