I am new to codeigniter and i tried a lesson from one of the tutorials but it throws the following error:
Class 'Controller' not found in
C:\xampp\htdocs\CodeIgniter\application\controllers\email.php
on line 3
My code:
<?php
class Email extends Controller{
function __construct()
{
parent::Controller();
}
function index()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'username' => '[email protected]',
'password' => 'password'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'Niroj Shakya');
$this->email->to('[email protected]');
$this->email->subject('This is a test email');
$this->email->message('Oops This is Great.');
if($this->email->send())
{
echo 'Your email was sent, FOOL';
}
else
{
show_error($this->email->print_debugger());
}
}
}
?>
What's the problem?
Change the class definition to
class Email extends CI_Controller {
and in the __construct function
parent::CI_Controller();
In CodeIgniter 2, the default controller is CI_Controller and the default model is CI_Model, whereas in CodeIgniter 1 they were just Controller and Model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With