<?

	error_reporting(E_ALL);
	ini_set("display_errors", 1); 

	$MAIL_LINE_BREAK = "\r\n";
	if	 (PHP_OS == "Linux") 	$MAIL_LINE_BREAK = "\n";
	
	$senderName		= ( isset($HTTP_GET_VARS['senderName'])		? $HTTP_GET_VARS['senderName']		: $HTTP_POST_VARS['senderName'] );
	$senderEmail	= ( isset($HTTP_GET_VARS['senderEmail'])	? $HTTP_GET_VARS['senderEmail']		: $HTTP_POST_VARS['senderEmail'] );
	$destiny		= ( isset($HTTP_GET_VARS['receiverEmail'])	? $HTTP_GET_VARS['receiverEmail']	: $HTTP_POST_VARS['receiverEmail'] );
	$subject		= ( isset($HTTP_GET_VARS['subject'])		? $HTTP_GET_VARS['subject']			: $HTTP_POST_VARS['subject'] );
	$content		= ( isset($HTTP_GET_VARS['message'])		? $HTTP_GET_VARS['message']			: $HTTP_POST_VARS['message'] );
	
	$destiny  = explode( ",", $destiny );

	$header  = "MIME-Version: 1.0" . $MAIL_LINE_BREAK; 
	$header .= "Content-type: text/html; charset=iso-8859-1" . $MAIL_LINE_BREAK;
	if	 (PHP_OS == "Linux")
	{
		$header  .= "From: $senderName <$senderEmail>" . $MAIL_LINE_BREAK;
		$header  .= "Return-Path: $senderName <$senderEmail>" . $MAIL_LINE_BREAK; // return-path
	}
	else
	{ 
		$header .= "From: $senderEmail" . $MAIL_LINE_BREAK;
		$header .= "Return-Path: $senderEmail" . $MAIL_LINE_BREAK; // return-path
	}


	$header .= "Reply-to: " . $senderEmail . $MAIL_LINE_BREAK;           
	if (is_array($destiny))
	{
		for ($i = 1; $i < count($destiny); $i++)
		{
			$header .= "Bcc: " . trim($destiny[$i]) . $MAIL_LINE_BREAK;		
		}		
	}
	$destiny = trim($destiny[0]);
	$r =  mail( $destiny, $subject, $content, $header );

	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>

<data>
	<result success="<?=($r ? "1" : "0")?>" />
</data>