Send Email Using PHPMailer and Codeigniter

Topics focus on Web Developments, Programming, Database, Digital Marketing Tutorials, Code Snippets, SEO, Social Media Marketing and Inspirational articles.

Send Email Using PHPMailer and Codeigniter

Send Email Using PHPMailer and Codeigniter

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.

CIPHP.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class CIPHP extends CI_Controller {
 
  function __construct(){
      parent::__construct();
      $this->load->library('phpmailer');
  }
  function send_email() {
 
      $subject = 'Testing Email';
      $name = 'iCoreThink Technologies';
      $email = 'contact@icorethink.com';
      $body = "This is body text for test email to combine CodeIgniter and PHPmailer";
      $this->phpmailer->AddAddress($email);
      $this->phpmailer->IsMail();
      $this->phpmailer->From = 'info@icorethink.com';
      $this->phpmailer->FromName = 'iCoreThink Technologies';
      $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.

Add comment


 

Pin It on Pinterest

Share This