<?php
include('data_handler.php');
$safeval = $_POST;
if(isset($safeval['datatype']) && $safeval['datatype'] == 'sbContactus') {
	if($safeval['action'] == 'sbcon_get_data') {
		
		require_once('swift/swift_required.php');
		
		$transport = Swift_MailTransport::newInstance();
		$mailer = Swift_Mailer::newInstance($transport);
		$safeval['name'] = stripslashes($safeval['name']);
		$safeval['name'] = stripslashes($safeval['name']);
        $safeval['email'] = stripslashes($safeval['email']);
		$safeval['message'] = stripslashes($safeval['message']);
		$safeval['message'] = stripslashes($safeval['message']);
		$subject = "Klamath Works Contact Form";
		$message = "<div style='font-family:arial,verdana;font-size:14px;color:#666666;'>
		<p>This email is from the contact us form on klamathworks.com. </p>
		<p><b>Name:</b> $safeval[name]</p>
		<p><b>Email:</b> $safeval[email]</p>
		<p><b>Message:</b> $safeval[message]</p>
		</div>";
		
		$from = array("admin@klamathworks.com" => "Admin");
		if($safeval['email'] != '') $from = array($safeval['email']=>$safeval['name']);
		//Email Setup
		$to = 'theworks@klamathworks.com';
		//$to = 'davidj@smithbates.com';
		$copy = array('davidj@smithbates.com');
		
		$content = Swift_Message::newInstance($subject)
					->setContentType("text/html")
					->setFrom($from)
					->setTo($to)
					->setBody($message);
					if(isset($copy)) $content->setBcc($copy);
					$headers = $content->getHeaders();
		$sendIt = $mailer->send($content);
	}
}

?>
