e-mail parameters-Codeigniter

The next thing that we will need to do is to set our e-mail parameters, the sender,
the recipient, any e-mail address to send a carbon copy or blind carbon copy to, the
subject of our e-mail, and the message body. Take a look at the following code and
see if you can distinguish the different parts of our e-mail:

$this->email->from('you@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@person.com');
$this->email->bcc('theboss@example.com');
$this->email->subject('Email Test');
$this->email->message('This is a simple test we wrote for the email
class.');


Hopefully you can read the previous code example pretty easily. This is one of the
benefits of CodeIgniter and its libraries. It's very easy to read CodeIgniter code. In
the first line of code we set our e-mail address, which is the address that we will send
the e-mail from, and also pass along a name to identify ourselves. In the next line,
we set the recipient, who is the person that we are sending the e-mail to. The next
line down is an e-mail address to send a carbon copy of the e-mail to. A carbon copy
is simply a copy of the e-mail, just sent to another person. The final line of the first
block is the e-mail address to which we will send a blind carbon copy to. A blind
carbon copy is the same as a carbon copy, except for the other recipients of the
e-mail do not know that this person also has received a copy of this e-mail.


Now, to send our e-mail we simply call the sendfunction of the e-mail library. Here's
how we do it.
$this->email->send();

There is another function available to us from this library. It's a debugger that echo's
out some information provided to us by the various mail sending protocols, and
we are also notified what has been sent and whether or not the e-mail was sent
successfully. To show the debugging information, we use the following line of code:
echo $this->email->print_debugger();

code looks like this:

$this->load->library('email');
$this->email->from('you@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@person.com');
$this->email->bcc('theboss@example.com');
$this->email->subject('Email Test');
$this->email->message('This is a simple test we wrote for the email
class.');
$this->email->send();
echo $this->email->print_debugger();


You are not just limited to sending e-mail from inside Controllers; e-mails can also be
sent from Models.
Related Posts:
  • Retrieving data-Codeigniter Retrieving POST data Toretrieve post data, you should use the function shown next. The first parameter is the name of the POST item that you are looking for.$this->input->post('some_field'); This function returns… Read More
  • CodeIgniter config.php The  config.php filecontains a series of configuration options all of them stored in a PHP array called, appropriately enough, $config) that CodeIgniter uses to keep track of your application ’ s  information and… Read More
  • Checking the values of the form-codeigniter Checking the values of the form-codeigniter We need to ensure that all of the form fields have been filled in. We can do this by simply using the empty()PHP function. Before we do this, we want to assign the value of th… Read More
  • codeigniter routes page The  routes.php filelets you remap URI requests to specific controller functions. For example, you may have a controller named sitewith a function named index. The URI for this controller/function combination might be… Read More
  • Codeigniter Database Library The  Database librarycontains a series of helpful functions that make it easy for you to create and run queries and process the result sets from those queries. The first thing to note about the Database library in Co… Read More
  • codeigniter-Creating loops Creating loops in view files has been a stumbling block for a few developers. By passing a multidimensional array to a view file, you can easily establish a loop in any of your view files. Let's take a look at an example.<… Read More
  • Mysql Join query Codeigniter Mysql Join query Codeigniter code loads and initializes the database class based on your configuration settings. $query = $this->db->query('SELECT name, title, email FROM my_table'); foreach ($query->result() … Read More
  • CodeIgniter models All CodeIgniter models have the same initial structure: < ?phpclass Page_model extends Model{function Page_model(){parent::Model();}}? > The first function is the code that retrieves the home page < ?phpclass P… Read More
  • e-mail parameters-Codeigniter The next thing that we will need to do is to set our e-mail parameters, the sender, the recipient, any e-mail address to send a carbon copy or blind carbon copy to, the subject of our e-mail, and the message body. Take a l… Read More
  • Codeigniter count_all for pagination work on count_all condition.. you can use below method to find out total number of rows.. public function count_all() { $this->db->select ( 'COUNT(*) AS `numrows`' ); $this->db->where ( array ( … Read More
  • Let's Make A Master Template codeigniter A simple CSS file, it ’ s time to create a generic Template view that you can reuse throughout your application. In this master template, which you can name template.php, are a series of embedded PHP calls that load certain … Read More
  • what is CodeIgniter Helpers? Helpers, as their name implies, help you with specific tasks. Unlike libraries, helpers are not object -oriented but procedural in nature. Each helper contains one or more functions, each focusing on a specific task, with ze… Read More
  • CodeIgniter system Folder The system/ folder is where all the action happens. This folder contains all the CodeIgniter code of consequence, organized into various folders: application —  The   application foldercontains the applicat… Read More
  • Top codeigniter interview question and answers codeigniter interview question  What is codeigniter? Codeigniter is open source , web application framework.Its is for building websites using php.Codeigniter is loosely based on MVC pattern.Most simple framework in ph… Read More