简体   繁体   中英

Codeigniter Sending An E-Mail Via A Function

I am getting a whole list of php errors but the main cause of the errors seem to be line 33 in my create function that is calling the userRegEmail function $this->_userRegEmail();

The general error that I am getting is:

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

Create Function:

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:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM