1. <?php  
  2.  
  3. /**
  4. * SENDS EMAIL WITH GMAIL
  5. */
  6.  
  7. class Email extends CI_Controller {
  8.         function __construct()
  9.         {
  10.             parent::__construct();
  11.         }
  12.        
  13.         function index()
  14.         {
  15.                 $config = Array(
  16.                         'protocol'  => 'smtp',
  17.                         'smtp_host' => "ssl://smtp.googlemail.com",
  18.                         'smtp_port' => 465,
  19.                         'smtp_user' => 'xxx',
  20.                         'smtp_pass' => 'zzz'
  21.                 );
  22.                
  23.                 $this->load->library('email', $config);
  24.                 $this->email->set_newline("\r\n");
  25.                  
  26.                 $this->email->from('xxx@gmail.com', 'Jack');
  27.                 $this->email->to('yyy@gmail.com');
  28.                 $this->email->subject('This is an email test');
  29.                 $this->email->message('It is working. Great!');
  30.                
  31.                 if($this->email->send())
  32.                 {
  33.                         echo 'Your email was sent, fool.';
  34.                 }
  35.                
  36.                 else
  37.                 {
  38.                         show_error($this->email->print_debugger());
  39.                 }
  40.         }
  41. }