Welcome Guest, Not a member yet? Register   Sign In
Error on tring set $this->email->from();
#1

[eluser]sn4k3[/eluser]
ERROR:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Email_model::$email

Filename: models/Email_model.php

Line Number: 12


Fatal error: Call to a member function from() on a non-object in D:\wamp\www\licitar\system\application\models\Email_model.php on line 12

Code:
Code:
<?php
/*
*    Send emails with HTML templates
*    Email Sender Wrapper
*/
class Email_model extends Model {

    function Email_model()
    {
        parent::Model();
        $this->load->library('email');
        $this->email->from(EMAIL_FROM);
        $this->email->reply_to(EMAIL_FROM, EMAIL_FROM_NAME);
    }
    
    /*
    *    Set email message, using HTML Template
    */
    function SetBody($template = NULL, $data)
    {
        if($template === NULL)
            $template = 'default';
        $this->email->message($this->load->view("emailtemplates/$template", $data, true));
    }
}
?>

Thanks
#2

[eluser]sn4k3[/eluser]
i fix, by replace constructor:

Code:
function Email_model()
    {
        parent::Model();
        $this->CI =& get_instance();
        $this->CI->load->library('email');
        $this->CI->email->from(EMAIL_FROM);
        $this->CI->email->reply_to(EMAIL_FROM, EMAIL_FROM_NAME);
    }




Theme © iAndrew 2016 - Forum software by © MyBB