<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once('application/libraries/mmail/htmlMimeMail.php'); 
	
class CI_Email extends htmlMimeMail5
{
	function __construct(){
		parent::__construct();
		$this->CI = &get_instance();	
	}
	
	function initialize($settings = false)
	{
        if(!$settings)
		{
			$settings = $this->CI->config->item('email');
		}
		
		$this->setSMTPParams($settings['host'],$settings['port'],$settings['helo'],$settings['auth'],$settings['user'],$settings['pass']);
		
		$this->setHTMLCharset('UTF-8');
        $this->setHeadCharset('UTF-8');
		$this->setHTMLEncoding(new EightBitEncoding());
		
	}
	
	function addOfficialImages()
	{
		$this->addEmbeddedImage(new fileEmbeddedImage('public/img/mail/title.jpg'));
		$this->addEmbeddedImage(new fileEmbeddedImage('public/img/mail/footer.jpg'));
	}
	
	function addImage($path)
	{
        $this->addEmbeddedImage(new fileEmbeddedImage('public/img/'.$path));
	}
	
	function clear()
	{
		$this->is_built = false;
		$this->setHTML(null);
		$this->setFrom(null);
	}
	
	function message($html)
	{
		$this->setHTML($this->CI->muser->string_to_code($html));
	}
	
	function from($from)
	{
		$this->setFrom($from);
	}
	
	function subject($subj)
	{
		$this->setSubject($subj);
	}
	
	
}