In CodeIgniter, sending e-mail is a simple process. First the library is loaded. Then the user provides e-mail related data. Finally, the E-mail is sent. Here is how E-mail is sent using a Controller in CodeIgniter
- Load the E-mail library of CodeIgniter
$this->load->library('email');
- Provide set of characters that are to be permitted in the E-mail address.
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_()@&\-!';
- Initialize the type of e-mail as html (options text or html)
$this->email->initialize(array('mailtype' => 'html'));
- Provide Sender’s E-mail address
$this->email->from('EMAIL ADDRESS OF SENDER', 'NAME OF SENDER');
- Provide Receiver’s E-mail Address
$this->email->to($RECEIVER_EMAIL_ADDRESS);
- Provide BCC E-mail address
$this->email->bcc('BCC_PERSON@codeonion.com');
- Provide Subject of the E-mail
$this->email->subject('THIS STRING IS THE SUBJECT OF EMAIL');
- Provide Body of the E-mail.
$this->email->message('Hello my E-mail Receiver. ');
- Send the E-mail!
$this->email->send();
Following is the complete code of the above process.
$this->load->library('email'); $config['permitted_uri_chars'] = 'a-z 0-9~%.:_()@&\-!'; $this->email->initialize(array('mailtype' => 'html')); $this->email->from('EMAIL ADDRESS OF SENDER', 'NAME OF SENDER'); $this->email->to($RECEIVER_EMAIL_ADDRESS); $this->email->bcc('BCC_PERSON@codeonion.com'); $this->email->subject('THIS STRING IS THE SUBJECT OF EMAIL'); $this->email->message('Hello my E-mail Receiver. '); $this->email->send();
Let me know in comments if there is something that you would like to know. And do like an share.
One response to “Codeigniter 2.20 – Sending E-mail using codeigniter”
it.s awesome post… I am so helpful for your review.