All posts in CodeIgniter

Send email with attachments in Codeigniter-series-3

We show how to send mail in codeigniter in http://learneveryday.net/php/framework/codeigniter/ci_series/sending-email-in-codeigniter/ . Today we will show how to send attachment. We just need to add two line of code to send attachment.
Bellow is the code.

<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
	function __construct()
	{
		parent::Controller();
	}
	
	function index() 
	{	

		

		$this->load->library('email');
		$this->email->set_newline("\r\n");
		
		$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
		$this->email->to('learneverydayTutorials@gmail.com');		
		$this->email->subject('This is an email test');		
		$this->email->message('It is working. Great!');
		
		
		$file =  './attachments/Info.txt';
		
		
		$this->email->attach($file);
		
		if($this->email->send())
		{
			echo 'Your email was sent, successfully.';
		}
		
		else
		{
			show_error($this->email->print_debugger());
		}
		
		
	}
}

?>
      

Continue reading →

Sending Email in CodeIgniter with gmail-series-2

Send mail in codeigniter is easy but using smtp by google is little tricky. Today we will show you how to send mail with smtp in gmail . Type the bellow code in your email.php in \application\controllers location. For us it is D:\xampp\htdocs\CodeIgniter\ci_series_2\application\controllers .

<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
	function __construct()
	{
		parent::Controller();
	}
	
	function index() 
	{	

		
		$config['protocol'] = 'smtp';
		$config['smtp_host'] = 'ssl://smtp.googlemail.com';
		$config['smtp_port'] = 465;
		$config['smtp_user'] = 'learneverydaytutorials@gmail.com';
		$config['smtp_pass'] = 'learneveryd@ytutorials';

	
		$this->load->library('email', $config);
		$this->email->set_newline("\r\n");
		
		$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
		$this->email->to('learneverydayTutorials@gmail.com');		
		$this->email->subject('This is an email test');		
		$this->email->message('It is working. Great!');
		
		
		if($this->email->send())
		{
			echo 'Your email was sent, successfully.';
		}
		
		else
		{
			show_error($this->email->print_debugger());
		}
	}
}

?>
      

Continue reading →

Sending Email in CodeIgniter-series-1

Sending mail in codeigniter is easy . Codeigniter has build in class on mail. You can easily configure it. Today we will see how to send mail . Latter tutorial we will see how to send mail in smtp.

Create a file email.php in D:\xampp\htdocs\CodeIgniter\ci_series_1\application\controllers
Write this code inside the email.php

<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
	function __construct()
	{
		parent::Controller();
	}
	
	function index() 
	{	
		$this->load->library('email');
		$this->email->set_newline("\r\n");
		
		$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
		$this->email->to('arifur.aiub@gmail.com');		
		$this->email->subject('This is an email test');		
		$this->email->message('It is working. Great!');
		
		
		if($this->email->send())
		{
			echo 'Your email was sent, successfully.';
		}
		
		else
		{
			show_error($this->email->print_debugger());
		}
	}
}

?>
      

Continue reading →

Setting up multiple applications with CodeIgniter

How can we use codeigniter framework directory to create multiple applications? Many times we need to run multiple codeigniter application . For all project we need the codeigniter system folder. If we copy the whole folder then it makes us trouble to update the codeigniter core. So that we use a unique codeigniter system for our multiple application. Lets see how we can do that.
The codeigniter structure is like this.
codeigniter file structure
Continue reading →

CodeIgniter: Choosing a Data From GET

CodeIgniter Step By Step Tutorial: At previous tutorial, we learn show a data. But we have define ID that we want to show. In this post, we learn how to show a data that ID defined from GET.

For model: Open “books_model.php” within CodeIgniter\system\application\models. Add following function:

<?php
	class Books_model extends Model{
	
	function Books_model(){

	parent::Model();

	}


	function books_get($id){

	$this->load->database();

	$query =$this->db->getwhere('books',array('id'=>$id));
	return $query->row_array();
	}

}
?>

Continue reading →