Monday, February 16, 2015

Sending Email With PHP Code Igniter

Follow These step :

1. Download PHPmailer from original site. Choose Zip Package.
2. Extract the downloaded “Zip” file.
3. Open the extracted file and copy “class.phpmailer.php” and “class.smtp.php”.
4. Paste these Two Files in Codeigniter Libraries.and rename it to be “phpmailer.php” and “smtp.php”




Create a controller file :


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  = 'Test Email';

$name = 'resta';

$email = 'resta_ok@yahoo.co.id';

$body = "body Message";

$this->phpmailer->AddAddress($email);

$this->phpmailer->IsMail();

$this->phpmailer->From     = 'info@resta-ok.co.id';

$this->phpmailer->FromName = 'user name';

$this->phpmailer->IsHTML(true);

$this->phpmailer->Subject  =  $subject;

$this->phpmailer->Body     =  $body;

$this->phpmailer->Send();

}

}

No comments:

Post a Comment