Published Mar 10,2019 by Kailash Singh
Sent Email Using Codeigniter

In this tutorial, we are going to learn about how to sent email using codeigniter.


Nowadays, pretty much every PHP structure bolsters a very much created email the executives library. CodeIgniter is the same as it has an incredible email sending class that guarantees that CodeIgniter undertakings could send messages without trouble.


Sending email in CodeIgniter is much easier. You also configure the preferences regarding email in CodeIgniter. CodeIgniter provides following features for sending emails −


  1.  Multiple Protocols − Mail, Sendmail, and SMTP
  2.  Multiple recipients
  3.  CC and BCCs
  4.  HTML or Plaintext email
  5.  Attachments
  6.  Word wrapping
  7.  BCC Batch Mode, enabling large email lists to be broken into small BCC batches.
  8.  Email Debugging tools


Step 1 :- Create Controller in Controller Folder (Email_sent.php)

   class Email_sent extends CI_Controller { 
      function __construct() { 
      public function index() 


Step 2 :- Create Html View in View Folder (email_form.php)

<!DOCTYPE html> 
<html lang = "en"> 

      <meta charset = "utf-8"> 
      <title>Sent Mail in Codeigniter</title> 
         echo $this->session->flashdata('mail_sent');
	  <fprm action="<?php echo base_url(); ?>mail_sent" method="post">
          <input type = "email" name = "email" required /> 
          <input type = "submit" value = "SEND MAIL"> 


Step 3 :- Create sent mail function in Controller (Email_sent.php)

    public function send_mail() {
        $from_email = "";//your mail
        $to_email = $this->input->post('email');
        $this->email->from($from_email, 'Identification');
        $this->email->subject('Demo Email by Codeigniter');
        $this->email->message('This email send by codeigniter only for testing');
        //Send mail
            $this->session->set_flashdata("mail_sent","Congratulation! Mail Sent Successfully.");
            $this->session->set_flashdata("mail_sent","Some errors....");
        return redirect('Email_sent')


Hope this will help our developers.

Because we believe Mantra means CodingMantra

1 Comment

Prabhat Singh said:

Thanks for the help

  • Mar 10, 2019

Leave a Reply