<?php

	/* Check Structure Availability */
	if (!defined("CORE_STRAP")) die("Out of structure call");
	/* Administrative restriction */
	(!me('is_administrator')&&!me('is_superadministrator')?die("Access restricted"):NULL);

	$tpl = new template;
	$tpl -> Load("testmail");


if(isset($_POST["send"])){

include("system/functions/classes/mail.class.php");

	// CONSTRUCTOR ///////////////////////////////////////////////////////////////////////////////////
	
	/* Create a new instance of the SendMail class */
	$mail = new SendMail;
	
	/*
		Sets the mailing method; mail, tinymail, smtp, sendmail
		mail: 		uses the PHP mail function with custom headers
		tinymail: 	uses the PHP mail function without any header
		smtp:		uses the SendMail Class SMTP client
		sendmail:	uses the server-side sendmail function
	*/
	$mail -> MailMethod = !empty($_POST["mailtype"]) ? $_POST["mailtype"] : "mail"; 

	$mail -> To = $_POST["email"];
	$mail -> From = isset($_POST["from"]) ? $_POST["from"] : $CONF["SITE_SYSTEM_EMAIL"];
	
	/* Mail Subject */
	$mail -> Subject = !empty($_POST["subject"]) ? $_POST["subject"] : "IZabi Mail Class Test";

	if($_POST["textformat"] == "text"){

	$mail -> Body = !empty($_POST["message"]) ? $_POST["message"] : "<plainmail>TEXT: uses <br />slah n for line breaks.<br />\n This<br />\n is<br />\n a plain part</plainmail>";

	} else $mail -> Body = !empty($_POST["message"]) ? $_POST["message"] : "<htmlmail>HTML: this uses &lt;br&gt; for line breaks <br /><strong>This</strong><br />is<br /> a HTML part</htmlmail> ";

	$mail -> SMTPHost = !empty($_POST["smtp_host"]) ? $_POST["smtp_host"] : "localhost";
	$mail -> SMTPUser = !empty($_POST["smtp_user"]) ? $_POST["smtp_user"] : false;
	$mail -> SMTPPassword = !empty($_POST["smtp_pass"]) ? $_POST["smtp_pass"] : false;
	
	/* Send the mail */
	if ($mail -> Send()) {	$tpl->Zone("testmail","success"); } else $tpl->Zone("testmail","failed");

} else {

$_POST["email"] = false;

$tpl->Zone("testmail","enabled");

}

$tpl->AssignArray(array("email"=>$_POST["email"]));

	
	// TEMPLATE REPROCESS & FLUSH ////////////////////////////////////////////////////
	$tpl -> CleanZones();

	/* Get the frame templates, flush the TPL result into it */
	$frame = new template;
	$frame -> Load("!theme/{$GLOBALS["THEME"]}/templates/admin/frame.tpl");
	$frame -> AssignArray(array(
		"jump" => $tpl->Flush(1)
	));
	
	/* Assign Location Value */
	$locationArray = explode(".", $_GET["L"]);
	for ($i=0; $i<count($locationArray); $i++) {
		$locationAppendResult[] = $locationArray[$i];
		if ($i > 0) $location[] = "<a href=\"?L=".implode(".", $locationAppendResult)."\">{$locationArray[$i]}</a>";
	}
	$frame -> AssignArray(array("location" => implode(" &raquo; ", $location)));
	
	/* Set the forced chromeless mode, flush the template */
	$GLOBALS["CHROMELESS_MODE"] = 1;
	$frame -> Flush();
	
?>