<?php
include_once("includes/email_layout_components.php");

switch($_GET['todo']) {
	case "send_mail":
		$returndata = prepare_and_send_mail();
	break;
}

function prepare_and_send_mail() {

	if(!allowed_email_access()) {
		return array('status' => false, 'errorMessage' => 'You are not allowed to use this function, exit!');
	}
	include(LANGUAGEFILE);
	
	$variables['html'] = true;
	$variables['to'] = check_vars($_GET['to']);
	$send_mail_settings = get_send_mail_settings();
	$variables['from'] = $send_mail_settings['from'];
	$variables['subject'] = check_vars($_GET['subject']);
	$variables['message'] = stripslashes(check_vars($_GET['message']));
	
	$returndata['status'] = true;
	
	if(send_mail($variables)) {
		$returndata['status'] = true;
		$returndata['popupMessage'] = $l_mail_sent;
	} else {
		$returndata['status'] = false;
		$returndata['errorMessage'] = 'Failed to send e-mail';
	}
	
	return $returndata;
}

?>