1. Email Library : CodeIgniter's robust Email Class library to make sending email very simple and easy.
2. Path Helper : The Path Helper file contains functions that permits you to work with file paths on the server.
Here is a basic example demonstrating how you might send email with attachment. Note: This example assumes you are sending the email from one of your controllers.
$this->load->library('email'); $this->load->helper('path'); $this->email->from('email@example.com', 'Your Name'); $this->email->to('firstname.lastname@example.org'); $this->email->cc('email@example.com'); $this->email->bcc('firstname.lastname@example.org'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); /* This function will return a server path without symbolic links or relative directory structures. */ $path = set_realpath('uploads/pdf/'); $this->email->attach($path . 'yourfile.pdf'); /* Enables you to send an attachment */ $this->email->send(); echo $this->email->print_debugger();
The above email sending example is used in CodeIgniter User Guide Version 2.1.4.