Send email using gmail in CodeIgniter

You can send email using gmail by using below code.

$this->load->library('email');
$aConfig = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Your gmail email',
'smtp_pass' => 'Your gmail password',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->email->initialize($aConfig);
$this->email->set_mailtype("html");
$this->email->from('Your from email', 'Your from name');
$this->email->to("Your receiver email");
$this->email->bcc("Your bcc email"); // optional
$this->email->subject("Your email subject");
$this->email->message("Your email body");
if($this->email->send())
{
echo "email sent";
}
else
{
echo "email not sent";
}