Codeigniter Отправка электронной почты через функцию - PullRequest
0 голосов
/ 03 марта 2012

Я получаю полный список ошибок php, но основная причина ошибок, кажется, line 33 в моей функции создания, которая вызывает userRegEmail функцию $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();
}

Ответы [ 2 ]

0 голосов
/ 07 января 2014
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(); 

   }
0 голосов
/ 03 марта 2012

В вашей функции create() измените вызов на

$this->_userRegEmail($activateCode, $email, $firstname, $lastname);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...