CodeIgniter Sending Email


CodeIgniter is a PHP framework for building web applications. To send an email using CodeIgniter, you can use the built-in email library.

To use the email library, you will first need to load it in your controller:


Next, you can configure the email settings, such as the email protocol, server details, and email address details.

$config = array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://',
  'smtp_port' => 465,
  'smtp_user' => '[email protected]',
  'smtp_pass' => 'your_email_password',
  'mailtype' => 'html',
  'charset' => 'iso-8859-1'

Next, you can set the email options and recipient:

$this->email->from('[email protected]', 'Your Name');
$this->email->to('[email protected]');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

Finally, you can send the email using the send() function:


You can also check for errors by using the print_debugger() function:

if (!$this->email->send()) {