Saturday, 17 September 2016

send email using SMTP config in codeigniter 3


send email using SMTP config in codeigniter 3

here example how to setup SMTP in codeigniter 3

first download the php mailler

put after extract foleder phpmailer folder move to codeigniter in application\libraries

after create libraries in  application\libraries create file my_phpmailer.php

here the code of my_phpmailer.php file

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

class My_PHPMailer {
    public function My_PHPMailer() {


3) Go To application\helpers create file  sendemails_helper.php

her code of header 

             function send_emails($emails,$body,$subject){
                    $mail = new PHPMailer;
                    $mail->Host = '';  //                               // Set mailer to use SMTP
                    $mail->SMTPAuth = true;                               // Enable SMTP authentication
                    $mail->Username = 'yahoomail';                 // SMTP username
                    $mail->Password = 'yahoopassword';                           // SMTP password
                    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
                    $mail->Port = 465;                                    // TCP port to connect to
                    $mail->setFrom('', 'title name');
                    $mail->addAddress($emails, 'user');
                    $mail->isHTML(true);                                  // Set email format to HTML
                    $mail->Subject = $subject;

after go to application\config open the file autoload.php

$autoload['libraries'] = array('database','session','My_PHPMailer');// here add you library My_PHPMailer

$autoload['helper'] = array('url', 'file','form','sendemails');// here add you helper file  sendemails

after when controler you want to send mail from smtp setup this helper function

    send_emails("","body content","subject"); 

here fully exmple of send email using SMTP config in codeigniter 3 please check it now

No comments:

Post a Comment

Thank You For Comment