Showing posts with label send mail using SMTP in php. Show all posts
Showing posts with label send mail using SMTP in php. Show all posts

Saturday, 3 December 2016

How to send Mail using SMTP in Codeigniter ?

Please Find following php script for send mail using SMTP







<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class SendMail extends CI_Controller {


public function __construct()
{
parent::__construct();

$config = Array(
               'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'amit*******@gmail.com',
    'smtp_pass' => '**********',
    'mailtype'  => 'html',
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
}



   public function index()
{

$this->email->from('amit@example.com', 'Amit Chouhan');
$this->email->to('to@gmail.com ');
$this->email->cc('cc@gmail.com');


$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();

}



}
?>

Email preferences are available at
https://www.codeigniter.com/user_guide/libraries/email.html