I have used the code bellow in order to send email, but does not work in local and live server?
//this function sends a confirmation email to the user while registration
public function send_email($email,$message,$subject) {
// configuration
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'example@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('example@gmail.com');
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($message);
$result = $this->email->send();
$this->email->clear();
return ($result);
}