douji9816 2016-01-22 04:31
浏览 41

从codeigniter中的另一个函数发送电子邮件 PHP

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();
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序