<?php
// +---------------------------------------------+
// |     Copyright  2007 - 2009 weenCompany      |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+

function sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort = 25)
	{
		include(INSTALL_PATH.'/../includes/mail/class.phpmailer.php');
		
			$mail = new PHPMailer();
			if($smtpChecked =='smtp')
				$mail->IsSMTP();
			else
				$mail->IsMail();

			$mail->Host = $smtpServer;
			$mail->Port = $smtpPort;
			$mail->CharSet = "utf8"; 
			$mail->Encoding = "base64"; 
			
			$mail->SMTPAuth = true;
			$mail->Username = $smtpLogin;
			$mail->Password = $smtpPassword;
				
			$mail->From      =  $from;   
			$mail->FromName  =  'weenCompany Test Mail';       
			$mail->AddAddress($to);
			
			$mail->Subject   = $subject;
			$mail->Body      = $content;
			
			return $mail->Send();
			
			

	}
	
$smtpChecked = (trim($_GET['mailMethod']) ==  'smtp');
$smtpServer = $_GET['smtpSrv'];
$content = $_GET['testMsg'];
$subject = $_GET['testSubject'];
$type = 'text/html';
$to =  $_GET['testEmail'];
$from = $_GET['smtpFrom'];
$smtpLogin = $_GET['smtpLogin'];
$smtpPassword = $_GET['smtpPassword'];
$smtpPort = $_GET['smtpPort'];

$result = sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort);

die($result ? '<action result="ok"/>' : '<action result="fail"/>');

?>