Welcome Guest, Not a member yet? Register   Sign In
Problem Email Class
#1

[eluser]Asinox[/eluser]
Well guys, hi... i dont know what happen today, but in my server i have more site's and there's working with the same configuration that this new one.

now i got the problem with the Email Class :


Fatal error: Call to a member function initialize() on a non-object in

and im loading the email class...

Code:
public function new_user(){

       $usuario = $this->userExists($this->input->post('usuario'));
       $email = $this->emailExists($this->input->post('email'));
      
       if($usuario==TRUE){
           return self::USED_USUARIO;
       }elseif($email==TRUE){
           return self::USED_EMAIL;
       }else{
        $hash['hash'] = sha1(md5(time().$this->input->post('email').$this->input->post('password')));
        $data = array('username'=>$this->input->post('usuario'),
                      'password'=>$this->encriptar($this->input->post('password')),
                      'email'=>$this->input->post('email'),
                      'nombre'=>$this->input->post('nombre'),                      
                      'apellidos'=>$this->input->post('apellidos'),    
                      'telefono'=>$this->input->post('telefono'),                      
                      'ciudad'=>$this->input->post('provincias'),                      
                      'celular'=>$this->input->post('celular'),                      
                      'hash'=>$hash['hash'],
                      'activo'=>self::INACTIVE_USER,
                      'fecha'=>date('Y-m-d h:i:s')
            );
        $this->db->insert(self::USER_TABLE,$data);
        
        if($this->db->affected_rows()>0){
            $config['wordwrap'] = TRUE;
            $config['mailtype'] = 'html';
            $config['priotity']=1;
            $config['protocol'] = 'sendmail';
            $config['mailpath'] = '/usr/sbin/sendmail';
            $config['charset'] = 'iso-8859-1';
            $this->email->initialize($config);
            $this->email->from('[email protected]', 'Hotelesdom.com');
            $this->email->to($this->input->post('email'));
            $this->email->subject('Registro en hotelesdom.com');
            $this->email->message('Gracias por registrarse en hotelesdom.com. Haga click aqui para confirmar su registro '. anchor(base_url().'cuenta/confirmar/'.$hash['hash']));
            $this->email->send();
            echo $this->email->print_debugger();
            //$this->email->clear();
        }
       }
}
#2

[eluser]Asinox[/eluser]
ok... i see that i can't send email from a model

Sad

that's true?

i moved my code to the controller and all is fine now ....
#3

[eluser]TheFuzzy0ne[/eluser]
I think you're problem is that you are loading the Email class before the model. If you do it the other way around, the model should be able to access the library. At the very worst case, you could probably just grab a reference to the CodeIgniter Super Object:

Code:
$CI =& get_instance();
$CI->load->library('email');
$CI->email->initialize($config);
#4

[eluser]Asinox[/eluser]
ok ,thanks for the tip about the super object Smile

but jeej now is working form the contoller, in the next site ill try with the Super Object




Theme © iAndrew 2016 - Forum software by © MyBB