1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Email_lib
{
private $CI;
public function __construct()
{
$this->CI =& get_instance();
$this->CI->load->library('email');
$config = array(
'mailtype' => 'html',
'useragent' => 'OSPOS',
'validate' => TRUE,
'protocol' => $this->CI->config->item('protocol'),
'mailpath' => $this->CI->config->item('mailpath'),
'smtp_host' => $this->CI->config->item('smtp_host'),
'smtp_user' => $this->CI->config->item('smtp_user'),
'smtp_pass' => $this->CI->encryption->decrypt($this->CI->config->item('smtp_pass')),
'smtp_port' => $this->CI->config->item('smtp_port'),
'smtp_timeout' => $this->CI->config->item('smtp_timeout'),
'smtp_crypto' => $this->CI->config->item('smtp_crypto')
);
$this->CI->email->initialize($config);
}
public function sendEmail($to, $subject, $message, $attachment = NULL)
{
$email = $this->CI->email;
$email->from($this->CI->config->item('email'), $this->CI->config->item('company'));
$email->to($to);
$email->subject($subject);
$email->message($message);
if( !empty($attachment) )
{
$email->attach($attachment);
}
$result = $email->send();
if(!$result)
{
error_log($email->print_debugger());
}
return $result;
}
}
?>