Send Email Using PHPMailer And Codeigniter

Request for callback

Details

Send Email Using PHPMailer and Codeigniter

CodeIgniter Email Class built for handling double-byte characters is really bad, cannot be properly set up Charest UTF-8.

Here We want to share some information to use Codeigniter and PHPmailer together. In this way, you can send any type of codes in Email Body.

We have to follow few steps to use PHPmailer with CodeIgniter.

1- Download PHPmailer from original site.
2- Extract the downloaded “Zip” file.
3- Open the extracted file and copy “phpmailer.php” and “class.smtp.php”.
4- Paste these Two Files in Codeigniter Libraries.
5- Now create now controller as I have following one.

 

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Message extends CI_Controller {

function __construct(){
parent::__construct();
$this->load->library('phpmailer');
}
function send_email() {

$subject = 'Testing Email';
$name = 'iQue Infotech';
$email = 'iqueinfotech@gmail.com';
$body = "This is body text for test email to combine CodeIgniter and PHPmailer";
$this->phpmailer->AddAddress($email);
$this->phpmailer->IsMail();
$this->phpmailer->From = 'xxxx@gmail.com';
$this->phpmailer->FromName = 'iQue Infotech';
$this->phpmailer->IsHTML(true);
$this->phpmailer->Subject = $subject;
$this->phpmailer->Body = $body;
$this->phpmailer->Send();

}
}

 

You simply need to pass values to this function and email is sent. To Read Simple PHPMailer to send email using PHP. Your controller is ready to send email using PHPMailer. This was simple, If you want to modify this controller, e.g you want to send html pages, you will kindly let me know, we will write another tutorial regarding this.

Related Updates

Send Attachments With PHP Mail()?

Send Attachments With PHP Mail()?

To send an email with attachment we need to use the multipart/mixed MIME type that specifies that mixed types will be included in the email. Moreover, we want to use multipart/alternative MIME type to ... Continue

How To Write Subquery In Codeigniter Active Record

How To Write Subquery In Codeigniter Active Record

CodeIgniter Active Records do not currently support sub-queries, However I use the following approach: $this->db->select('id');$this->db->from('table');$where_clause = $this->db- ... Continue

PHP Development Rajkot - Jamnagar

PHP Development Rajkot - Jamnagar

PHP development services in All countries. With the remarkable experience, our experts have enabled us to become a trusted PHP development service.Custom PHP DevelopmentWe build custom websites that ... Continue



Location

Shopali Building , Ghandhi ChowkDhrol-361210 Gujarat(India)
MoTuWeThFrSaSu
Open11:00 AM To 7:00 PM
Request For Quotation
Ique Infotech All rights reserved - Copyright © 2026
Powered by 4allBIZ