Send email using codeigniter?

In this article I will explain you how to send email using codeigniter.Codeigniter have library for email feature. You just need to autoload that library.Isn’t it very simple?

Codeigniter supported inbuilt Email library class which simplify the email sending process. To send email we need to do some configuration , need to load email library.codeigniter supports Multiple Protocols, Mail, Sendmail, and SMTP, Multiple recipients, CC and BCCs, HTML or Plain text email, Attachments ,Word wrapping and many more feature.So lets start and do some codeing stuff for Send email using codeigniter.
First create a controller in the Controller folder name with Email.php

Now copy and paste the following code

Email.php   
<?php
 defined('BASEPATH') OR exit('No direct script access allowed');
 class Email extends CI_Controller {
 public function __construct() {
 parent::__construct();
 $this->load->helper(array('url'));
 $this->load->model('user_model');
 }
 
 public function sendEmail(){
    //now copy and paste the below code
    $this->load->library('email');  
    $html = "Test email";
     $email_setting = array('mailtype'=>'html');
     $this->email->initialize($email_setting);
     $this->email->from('TEST');
     $this->email->to('the email address');
     $this->email->subject('Title': 'New email');
     $this->email->message($html);
     $this->email->send();
}
 
}
Now Run the sendEmail function.

Hope this article will help You. Keep reading.