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

/**
 * Library Make Mail
 *
 * This class handles mail related functionality
 *
 * @package     DA
 * @author      DK
**/

class Make_mail {
	
	public function send($recipient = NULL, $subject = NULL, $message = NULL, $mail_type = NULL)
	{	
		$CI 			=& get_instance();
		
		if(empty($CI->settings->smtp_server) || empty($CI->settings->smtp_username) || empty($CI->settings->smtp_password) || empty($CI->settings->smtp_port) || empty($CI->settings->sender_email))
		{
			return TRUE;
		}

		$CI->load->library('email');

		$config 				= array();

		// Send email 
		$config['protocol']		= 'smtp';
		$config['smtp_host'] 	= $CI->settings->smtp_server;
		$config['smtp_port'] 	= $CI->settings->smtp_port;
		$config['smtp_user'] 	= $CI->settings->smtp_username;
		$config['smtp_pass'] 	= $CI->settings->smtp_password;
		$config['useragent'] 	= $CI->settings->site_name;
		
		$config['charset'] 		= "utf-8";
		$config['mailtype'] 	= "html";
		$config['newline'] 		= "\r\n";
		
		$CI->email->initialize($config);
		
		$CI->email->set_header('Content-Type', 'text/html');
		$CI->email->from($CI->settings->sender_email, $CI->settings->site_name);
		$CI->email->to($recipient);
		$CI->email->reply_to($CI->settings->site_email, $CI->settings->site_name);

		$CI->email->subject($subject);
		$CI->email->message($message);
		    
		$CI->email->send();
	}
}

/*End Make Mail*/