I am calling a function (mail) from another function (forget) to send mail by passing argument like $to & $msg. but every time i run the code it says that "cant load the email library" but when i run the same code without calling of function it smoothly send the mail.
public function forget(){
$this->load->library('session');
$this->load->helper('form');
$this->load->database();
$this->load->model('Session_eg_model');
$to=$this->input->post('email');
$otp=mt_rand(100000, 999999);
$response=$this->Session_eg_model->forget_pass($to,$otp);
if($response==101){
echo "Enter correct mail";
}
else{
$msg="Use this new password ".$otp." to login ";
$this->mail($to,$msg);
$this->load->view('session_pass_view');
}
}
public function mail($to,$msg){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '****@gmail.com',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("
");
$this->email->from('prateek.singhglavvdn@gmail.com', 'prateek');
$this->email->to($to);
$this->email->subject('password recovery');
$this->email->message($msg);
$this->email->send();
}