$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$messageBody = "";
if($_POST['name']!='nope'){
$messageBody .= '
Visitor: ' . $_POST["name"] . '
' . "\n";$messageBody .= '
' . "\n";
}
if($_POST['email']!='nope'){
$messageBody .= '
Email Address: ' . $_POST['email'] . '
' . "\n";$messageBody .= '
' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='nope'){
$messageBody .= '
State: ' . $_POST['state'] . '
' . "\n";$messageBody .= '
' . "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= '
Phone Number: ' . $_POST['phone'] . '
' . "\n";$messageBody .= '
' . "\n";
}
if($_POST['fax']!='nope'){
$messageBody .= '
Fax Number: ' . $_POST['fax'] . '
' . "\n";$messageBody .= '
' . "\n";
}
if($_POST['message']!='nope'){
$messageBody .= '
Message: ' . $_POST['message'] . '
' . "\n";}
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
?>