<?php
$paths = array(
	".",
	"..",
	"../..",
	"../../..",
	"../../../..",
	"../../../../..",
	"../../../../../..",
	"../../../../../../..",
	"../../../../../../../.."
);

foreach($paths as $path) 
{
	if(@include( $path.'/wp-load.php'))
	{
		break;
	}
}

$form_mail = get_option('siteadmin_email', get_bloginfo('admin_email')); 


$name = $_REQUEST["Name"];
$email = $_REQUEST["Email"];
$subject = $_REQUEST["Subject"];
$message_content = $_REQUEST["Message"];
	
//-----------------------------------------------------
//-----------------------------------------------------
$address = $form_mail;
$sender = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $email . ">";
$subject_utf  =  mb_encode_mimeheader($subject,"UTF-8", "B", "\n");

//-----------------------------------------------------
//-----------------------------------------------------


function sendMail($from, $to, $subject, $plain, $html = false, $charset = "iso-8859-1") {

	$cur_lb = get_option("email_set", "LF");
	
	if($cur_lb == "CRLF"){
		$lb = "\r\n";
	}else if($cur_lb == "LF"){
		$lb = "\n";
	}

	if($html == false) {

		$headers = "From: ".$from.$lb;
		$headers .= "Reply-To: ".$from.$lb;
		$headers .= "MIME-Version: 1.0".$lb;
		$headers .= "X-Priority: 3".$lb;
		$headers .= "X-Mailer: RobustMail [1.0]".$lb;
		$headers .= "Content-type: text/html; charset=".$charset.$lb;
		$mail_sent = @mail($to, $subject, $plain, $headers);
		return $mail_sent;

	}

	$random_hash = md5(microtime());
	$headers = "From: ".$from.$lb;
	$headers .= "Reply-To: ".$from.$lb;
	$headers .= "MIME-Version: 1.0".$lb;
	$headers .= "X-Priority: 3".$lb;
	$headers .= "X-Mailer: RobustMail [1.0]".$lb;
	$headers .= "Content-Type: multipart/alternative;".$lb."\tboundary=\"bo_".$random_hash."\"";

ob_start();

?>
--bo_<?php echo $random_hash.$lb; ?>
Content-Type: text/plain; charset = "<?php echo $charset; ?>"
Content-Transfer-Encoding: 7bit

<?php echo $plain; ?>


--bo_<?php echo $random_hash.$lb; ?>
Content-Type: text/html; charset = "<?php echo $charset; ?>"
Content-Transfer-Encoding: 7bit

<?php echo $html; ?>




--bo_<?php echo $random_hash; ?>--
<?php
	$message = ob_get_clean();
	$to = is_array($to) ? implode(", " , $to) : $to;
	$mail_sent = @mail($to, $subject, $message, $headers);
	return $mail_sent;
}
ob_start();
?>
You got an email from your website!<br />
----------------------------------------<br />
Name : <?php echo $name; ?><br />
Email : <?php echo $email; ?><br />
Subject : <?php echo $subject; ?><br />
Message : <?php echo $message_content; ?><br />
<?
$mailBody = ob_get_clean();
$send_mail = sendMail($sender, $address, $subject_utf, $mailBody, $html = false, $charset = "utf-8");
echo $send_mail ? "Mail sent" : "Mail failed";
?>