Code Igniter 2 Libraries Email got error

时间:2017-05-10 09:11:54

标签: php sql-server codeigniter email iis-8.5

晚安,

我在IIS 8.5和MSSQL Server上使用CodeIgniter 2, 当我尝试在此过程中发送电子邮件时,它会显示错误:

  

严重性:注意

     

消息:遇到未正确形成的数值

     

文件名:libraries / Email.php

     

行号:1689

我一直在同一服务器上的某些项目中使用此代码,并且它正常工作。但是,当我尝试在此实施时,它总是在每次发送电子邮件过程时都会显示此错误。

这是我的控制者:

function reset_pass() {
    if (!IS_AJAX) {
        display_nonajax_stop();
        exit;
    } else {
        $settings = $this->m_setting->get_setting_array();
        $min_pass_length = (int) $settings["acc_pass_min_length"];
        $data = $this->input->post();
        $id = $data['id'];
        $hasil = array();

        $kondisi = array(
            "usr_id" => $id
        );
        $current_time = waktu_sekarang();
        $baris = $this->m_ess->get_user_employee_row($kondisi);
        $user = $baris;
        if ($user->usr_email === NULL) {
            $hasil['pesan'] = "User  does not have valid email associated . Please contact Administrator.";
            $hasil['status'] = 0;
        } else {
            $this->load->helper('email');
            if (!valid_email($user->usr_email)) {
                $hasil['pesan'] = "User does not have valid email associated . Please contact Administrator.";
                $hasil['status'] = 0;
            } else {

                $hasil['pesan'] = "Username and email is ok";
                $hasil['status'] = 0;

                $this->load->library('rndconditionpass');
                $tmppass = $this->rndconditionpass->get_random_string($min_pass_length);
                $new_password = $this->bcrypt->do_hash($tmppass);                    

                $mail_data['random'] = $tmppass;
                $mail_data['username'] = $user->usr_name;
                $mail_data['full_name'] = $user->emp_name;
                $mail_data['password'] = $tmppass;


                //prepare data to be used in leo_mail library
                $param = array();
                $param['recipient'] = $user->usr_email;
                $param['content'] = $this->load->view("template/mail/mail_reset_pass", $mail_data, TRUE);
                $param['subject'] = "Reset Password";

                $this->load->library('leo_mail');
                $kirim = $this->leo_mail->kirim($param);

                if ($kirim['status'] == 1) {

                    #password history
                    $insert_pass = array(
                        "pas_usr_name" => $user->usr_name,
                        "pas_password" => $new_password,
                        "pas_date" => $current_time,
                        "pas_opid" => $this->session->userdata("usr_name"),
                        "pas_update" => $current_time
                    );
                    $this->m_pass->insert_pass($insert_pass);

                    $hasil['pesan'] = "Password has been reset and user has been notified via email. ";
                    $hasil['status'] = 1;
                    //update the database, store the reset code
                    $update = array();
                    $update['usr_last_cpass'] = date("Y-m-d H:i:s");
                    $update['usr_needchgpwd'] = "Y";
                    $update["usr_password"] = $new_password;

                    $kondisi = array("usr_name" => $user->usr_name);
                    $q = $this->m_ess->update_user($update, $kondisi);
                } else {
                    $hasil['pesan'] = "Fail to send email your password reset code.";
                    $hasil['status'] = 0;
                }
            }
        }

        echo json_encode($hasil);
    }
}

这里是' $ this-> leo_mail-> kirim函数

function kirim($param) {

        $q=$this->ci->m_smtp->get_mail_konfig();
        $hasil=array();
        if($q->num_rows()<1) {
            $hasil['pesan']="Your SMTP configuration has not been set up properly";
            $hasil['status']=0;                                    
        } else {
            if(valid_email($param['recipient'])) {
                $config=array();
                $config_data= $q->row();
                $config['protocol'] = "smtp";
                $config['useragent'] = "HRISSMTPLIB";
                $config['smtp_port'] = $config_data->smt_smtp_port;
                $config['smtp_host'] = $config_data->smt_smtp_host;
                $config['smtp_user']= $config_data->smt_smtp_user;                                
                $config['smtp_pass']= $this->ci->leo_enkripsi->decrypt($config_data->smt_smtp_pass,$this->key);

                $config['newline']="\r\n";
                $config['wordwrap'] = FALSE;
                $config['starttls']=($config_data->smt_encrypt_type==3)?TRUE:FALSE;
                $config['mailtype'] = "html";

                $this->ci->email->initialize($config);
                $this->ci->email->from($config_data->smt_email,$config_data->smt_name);
                $this->ci->email->to($param['recipient']);

                $this->ci->email->subject($param['subject']);
                $this->ci->email->message($param['content']);

                if($this->ci->email->send()) {
                     $hasil['pesan']="Email sent";
                     $hasil['status']=1;
                } else {
                     $hasil['pesan']= $this->ci->email->print_debugger();
                     $hasil['status']=0;
                }   
            } else {
                $hasil['pesan']="Recipient email is not valid";
                $hasil['status']=0;
            }                                                        
        }                               
        return $hasil;
    }

抱歉我的英语不好。

提前谢谢。

0 个答案:

没有答案