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.