<?php
// запрет прямого доступа
defined('_JEXEC') or die('Restricted access');

require_once 'PHPMailer/class.phpmailer.php';
require_once 'PHPMailer/class.smtp.php';

class mail_controller{
	private $address = 'mta.emailmatrix.ru';
	private $port    = 465;
	private $login   = 'tools@emailmatrix.ru';
	private $pwd     = 'iwV8ZcHMVGoY';
	private $from    = 'tools@emailmatrix.ru';
	var $emails 	 = array('lera.larionova@emailmatrix.ru', 'anton.chirkov@emailmatrix.ru');
	var $error;
	
	function __construct(){
		
		
	}
	function send($html, $title, $emails = false){
		if (!$emails){
			$emails = $this->emails;
		}
		
		$mail_sended = new PHPMailer();
		$mail_sended->isSMTP();
		$mail_sended->Host 			= $this->address;
		$mail_sended->Username 		= $this->login;
		$mail_sended->Password 		= $this->pwd;
		$mail_sended->Port 			= $this->port;
		$mail_sended->From 			= $this->login;
		$mail_sended->SMTPAuth 		= true;
		$mail_sended->SMTPSecure 	= 'ssl';
		$mail_sended->FromName 		= 'EMAILMATRIX reports';
		$mail_sended->CharSet 		= 'utf-8';		
		$mail_sended->Subject 		= $title;
		$mail_sended->Body    		= $html;
		$mail_sended->isHTML(true);	
		
		foreach($emails as $email){
			$mail_sended->addAddress($email);
		}

		if ($mail_sended->send()){
			$mail_sended = true;
		} else {
			echo 'Ошибка'.$mail_sended->ErrorInfo;
			$mail_sended = false;
		}
	}
	
}