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

[eluser]brandobandido[/eluser]
Hi CI Masters,

I need your enlightenment here as I'm stumbled again to another CI issue that I can't seem to resolve since last night.

Ok here's the situation. I created a method that's under the Functions library that uses the email class functionality. Below's my code.

Code:
/**
     * Send email function
     *
     * @param array $data
     */

    function sendEmail($data = array())
    {
        $CI =& get_instance();
        $CI->email->from($data['email_from'], $data['email_from_name']);
        $CI->email->to($data['email_to']); // To user
        $CI->email->subject($data['email_subject']);
        $CI->email->message($data['email_message']);
        $CI->email->send();
        // Show the message for debugging
        echo $CI->email->print_debugger();
    }

And in my controller, I called it this way

Code:
$send_email_array = array(
                        'email_from' => '[email protected]',
                        'email_from_name' => 'Test site',
                        'email_to'  => '[email protected]',
                        'email_subject' => 'Subject',
                        'email_message' => 'Message here'
                    );
                    $this->functions->sendEmail($send_email_array);

The Functions library was already auto loaded but when I execute it I get this error

Code:
Fatal error: Call to a member function from() on a non-object in /path/site/system/applications/backend/libraries/Functions.php on line 160

I really don't understand why $CI =& get_instance() is not anymore an object.

Your help would be greatly appreciated as always!

Regards


Messages In This Thread
Error using Email Class - by El Forum - 04-16-2011, 02:46 AM
Error using Email Class - by El Forum - 04-16-2011, 02:56 AM
Error using Email Class - by El Forum - 04-16-2011, 05:51 AM
Error using Email Class - by El Forum - 04-16-2011, 08:49 AM
Error using Email Class - by El Forum - 04-16-2011, 09:43 AM
Error using Email Class - by El Forum - 04-16-2011, 10:23 AM
Error using Email Class - by El Forum - 04-16-2011, 11:45 AM
Error using Email Class - by El Forum - 04-16-2011, 08:39 PM
Error using Email Class - by El Forum - 04-16-2011, 11:22 PM
Error using Email Class - by El Forum - 04-17-2011, 12:35 AM
Error using Email Class - by El Forum - 04-17-2011, 12:51 AM
Error using Email Class - by El Forum - 04-17-2011, 05:01 AM
Error using Email Class - by El Forum - 04-17-2011, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB