Send Email using Codeigniter Email library

Send Email using Codeigniter Email library

In this post, I would like to show how to send email using codeigniter email library. Codeigniter supported inbuilt library class. You just need to load library and this will make easy to sending emails.
1.) Create a view file called email inside myapp/application/views.

<title>Email using Codeigniter library</title>
font-family: Verdana;
font-size: 18pt;
font-style: normal;
font-weight: bold;
text-align: center;
font-family: Verdana;
font-size: 12pt;
font-style: normal;
font-weight: bold;
border-collapse: collapse;
  font-size: 11px;
<h3>Send Email Using Codeigniter Library</h3>
<?php echo form_open('email/send',array('name'=>'email')); ?>
    <table align="center" cellpadding = "5">
            <td colspan="5" align="center">
            <input type="submit" name="send" value="Send Email"/></td>
<?php echo form_close();?>

2.) Create a controller called EmailController inside myapp/application/controllers to put all send email functionality.Please find below the code.


defined('BASEPATH') OR exit('No direct script access allowed');
class EmailController extends CI_Controller {
publicfunction __construct()
    public function index(){
publicfunction send(){
$message_body = "Hello<br><br>Greetings!<br><br>You are just a step away from accessing your account.<br><br>We are sharing a Login credentials to access your account.<br><br>Once you Login, you'll be prompted to set a new password immediately. This is to ensure that only you have access to your account.";
$this->email->from('','Techalltype'); /*// The email address and name of the person sending the email */
$this->email->to(''); /*// The email address(s) of the recipient(s). Can be a single email , a list separated with comma or an array */
$this->email->subject('Techalltype : Login Credentials');

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – let us know. We’d love to help!