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

if (! function_exists('send_mail')) {

	function send_mail($email, $url, $subject, $template) 
    {
        $CI =& get_instance();
        
        $CI->load->library('email');
        
        $data_email = array(
            'url' => $url
        );
        
        $config['protocol'] = 'mail';
        $config['mailpath'] = '/usr/sbin/sendmail';
        $config['wordwrap'] = TRUE;
        $file = 'email/'.$template;
        Template::load_view($file, $data_email, '', '', $view);
        //var_dump($data_email);break;
        
        //$CI->email->message($view);
        $CI->email->initialize($config);
        $CI->email->to($email);
        $CI->email->from('contato@viewbrasil.com.br', "View Brasil - Marketing Digital");
        $CI->email->subject($subject);
        $CI->email->message($view);
        
        if ($CI->email->send()) 
        {
            return true;
            
        } 
        else
        {
            return false;
        }
    }
    
}