<?php
	
	$subject = "Website Contact Form";
	// the subject of the email
	
	$name = $_POST['username'];
	$email = $_POST['email'];
	$message = $_POST['message'];
	
	$admin_email = get_settings('admin_email');
	

	// don't change anything else
	if($_POST['submit'])
	{
	
        if(!ereg("^[A-Za-z0-9\.|-|_]*[@]{1}[A-Za-z0-9\.|-|_]*[.]{1}[a-z]{2,5}$", $email) || $email == "") 
		{
        	echo "<p class='bad'>Message was not sent. Please enter in a valid email address.</p>";
        }

		elseif($message == "")
		{
			echo "<p class='bad'>Message was not sent. Please don't forget your message.</p>";
		}
		
		elseif($name == "")
		{
			echo "<p class='bad'>Message was not sent. Please don't forget your name.</p>";
		}
		
		else
		{
			$message = "About: $property\nemail: $email\nmessage:\n$message";
			
			mail($admin_email, $subject, $message, "From: $name\r\nReply-to: $email\r\n");
	
			echo "<p class='good'>Message sent successfully! We'll get back to your shortly.</p>";
			
		}
	}
?>