Reputation: 2823
im trying to teach myself codeignighter and currently learning sending emails.
I am trying to load the email library and i keep getting "Undefined property: Email::$load" error.
Ive tried for the last hour to find the problem but cant find out whats wrong, any help is much appreciated.
my email.php
<?php
class Email extends CI_Controller
{
function __construct()
{
parent::get_instance();
}
function index()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '****[email protected]',
'smtp_pass' => '******'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('****@gmail.com' , 'joe blog');
$this->email->to('****@gmail.com');
$this->email->subject('this is a test');
$this->email->message('it is working .... great!');
if($this->email->send())
{
echo 'your email was sent';
}
else
{
show_error($this->email->print_debugger());
}
}
}
Upvotes: 0
Views: 1164
Reputation: 92
i had the same error.
Try to load email library, and then the email configuration like this:
// email
$this->load->library('email');
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => '********@gmail.com', // your user.
'smtp_pass' => '****' // your password
);
$this->load->library('email', $config);
Here you have the official documentarion about it:
http://www.codeigniter.com/user_guide/libraries/email.html
Regards.
also as mentioned from @ devpro
use
parent::__construct();
Upvotes: 2