Tutorial by Examples

First you need to load the email library. Do this either in the controller file that will be sending the email: $this->load->library('email'); Or load it globally in the autoload.php file in the config folder: $autoload['libraries'] = array('email'); While you're there, you may want t...
Create a new file in the application/config folder named email.php Set the parameters for sending email. These will load when you send your email. $config['newline'] = "\r\n"; //You must use double quotes on this one $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmai...
$this->email->from('[email protected]', 'Tom Webmaster'); $this->email->to('[email protected]', 'Freddie Fakeperson'); $this->email->subject('Your Account Is Active'); $this->email->message('Welcome to our new site!'); In the 'from' method, the first parameter is the...
$sent = $this->email->send(); //This is optional - but good when you're in a testing environment. if(isset($sent)){ echo "It sent!"; }else{ echo "It did not send."; }
But you don't just want a plain text email. You want a pretty html email. Set your config file as html: $config['mailtype'] = 'html'; If you want to pass data (like a username for example) to the html email, put them in an array: $data = array('name' => $name, 'email' => ...
Controller (Pages.php) public function contact() { $this->load->library('email'); $this->load->library('form_validation'); //Set form validation $this->form_validation->set_rules('name', 'Name', 'trim|required|min_length[4]|max_length[16]'); $this...

Page 1 of 1