title: Sending email with gmail smtp with codeigniter email library
body: <pre><code>&lt;?php
  class Email extends Controller {
  
      function Email()
      {
          parent::Controller();   
          $this-&gt;load-&gt;library('email');
      }
  
      function index()
      {
          $config['protocol']    = 'smtp';
          $config['smtp_host']    = 'ssl://smtp.gmail.com';
          $config['smtp_port']    = '465';
          $config['smtp_timeout'] = '7';
          $config['smtp_user']    = 'mygmail@gmail.com';
          $config['smtp_pass']    = '*******';
          $config['charset']    = 'utf-8';
          $config['newline']    = "\r\n";
          $config['mailtype'] = 'text'; // or html
          $config['validation'] = TRUE; // bool whether to validate email or not      
  
          $this-&gt;email-&gt;initialize($config);
  
          $this-&gt;email-&gt;from('mygmail@gmail.com', 'myname');
          $this-&gt;email-&gt;to('target@gmail.com'); 
  
          $this-&gt;email-&gt;subject('Email Test');
          $this-&gt;email-&gt;message('Testing the email class.');  
  
          $this-&gt;email-&gt;send();
  
          echo $this-&gt;email-&gt;print_debugger();
  
          $this-&gt;load-&gt;view('email_view');
      }
  }
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>A PHP Error was encountered
  Severity: Warning
  Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)
  Filename: libraries/Email.php
  Line Number: 1641
  </code></pre>
  
  <p>Using <code>PORT 25/587</code></p>
  
  <p>I got this error:</p>
  
  <pre><code>A PHP Error was encountered
  Severity: Warning
  Message: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252)
  Filename: libraries/Email.php
  Line Number: 1641
  </code></pre>
  
  <p>I don't want to use phpmailer now. (Actually I have tried to use phpmailer, but I failed).</p>
  
  <p>How do I solve this problem guys?</p>