簡體   English   中英

Codeigniter通過功能發送電子郵件

[英]Codeigniter Sending An E-Mail Via A Function

我得到了一個完整的PHP錯誤列表,但錯誤的主要原因似乎是我的create函數(調用userRegEmail函數$this->_userRegEmail(); line 33 $this->_userRegEmail();

我得到的一般錯誤是:

Message: Missing argument 1 for Users::_userRegEmail(), called in line 33 and defined

創建功能:

public function create(){   

        //If form validation fails load previous page with errors else do the job and insert data into db

        if($this->form_validation->run('createUser') == FALSE)
        {
            $data['success'] = "";
        }else{
            $username = $this->input->post('userName');
            $password = $this->input->post('userPassword');
            $firstname = $this->input->post('userFirstName');
            $lastname = $this->input->post('userLastName');
            $email = $this->input->post('userEmail');

            $passwordHash = $this->encrypt->sha1($password); // Lets encrypt the password why sha1?  MD5 is for tossers

            $activateCode = $this->_activateCode(10);

            $this->_userRegEmail();

            // If the data is correct follow through with db insert

            if($this->users_model->createUser($username,$passwordHash,$firstname,$lastname,$email,$activateCode))
            {
                $this->session->set_flashdata('success','Thank's ' . $firstname . ' please check your email for confirmation');

                redirect('users/create' , 'refresh');

            }

        }
        $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
        $data['pageTitle'] = "Create User";
        $this->load->view('frontend/assets/header', $data);
        $this->load->view('frontend/user_create', $data);
        $this->load->view('frontend/assets/footer');
    }

_userRegEmail()函數:

function _userRegEmail($activateCode,$email,$firstname,$lastname){
    $data['companyName'] = $this->core_model->companyDetails()->coreCompanyName;
    $data['companyEmail'] = $this->core_model->companyDetails()->coreCompanyEmail;
    $data['companyContact'] = $this->core_model->companyDetails()->coreContactName;
    $data['firstName'] = $firstName;
    $data['lastName'] = $lastname;
    $data['email'] = $email;
    $data['activateCode'] = $activateCode;

    $this->email->from($this->core_model->companyDetails()->coreCompanyEmail, $this->core_model->companyDetails()->coreCompanyName);
    $this->email->to($email);
    $this->email->subject($this->core_model->companyDetails()->coreCompanyName, 'User Registration Confirmation');

    $messageContent= $this->load->view('email_templates/userReg','', TRUE);

    $this->email->message($messageContent);

    $this->email->send();
}
function sendemail()
{
   $activateCode  =  $this->random_string(10);; 
   $email;        =  $this->input->post('email'); 
   $firstname     =  $this->input->post('firstname'); 
   $lastname      =  $this->input->post('lastname');

  $this->load->library('email');
    $this->email->from(youremailaddress@gmail.com', 'Your name');
    $this->email->to($email);
    $this->email->subject('Registration Confirmation');
    $this->email->message('Click the link below to activate your account' . anchor('http://localhost/testproject/index.php/user/confirmation_activation/' . $activation_code,'Confirmation Register'));*/

    $this->email->send(); 

   }

在您的create()函數中,將調用更改為此

$this->_userRegEmail($activateCode, $email, $firstname, $lastname);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM