title: Codeigniter Sending Email throwing error
body: <p>I am spending hours trying to send email in CI from server. In localhost, it worked fine. </p>
  
  <p>In <strong>config/email.php</strong> I have added the following:</p>
  
  <pre><code>$config['mailtype'] = 'html';
  $config['protocol'] = 'smtp';
  $config['smtp_host'] = 'ssl://smtp.gmail.com';    
  $config['smtp_port'] = 465;
  $config['smtp_user'] = 'username@gmail.com';
  $config['smtp_pass'] = '*******';
  $config['charset'] = 'iso-8859-1';
  $config['newline'] = "\r\n";
  </code></pre>
  
  <p>and in <strong>auth.php</strong>(I am using tank auth) in function for sending email, I have added this,</p>
  
  <pre><code>$this-&gt;load-&gt;library('email');
  $this-&gt;email-&gt;set_newline("\r\n");
  </code></pre>
  
  <p>I am getting errors as:</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Warning
  
  Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
  
  Filename: libraries/Email.php
  
  Line Number: 1689
  
  A PHP Error was encountered
  
  Severity: Warning
  
  Message: fwrite() expects parameter 1 to be resource, boolean given
  
  Filename: libraries/Email.php
  
  Line Number: 1846
  
  A PHP Error was encountered
  
  Severity: Warning
  
  Message: fgets() expects parameter 1 to be resource, boolean given
  
  Filename: libraries/Email.php
  
  Line Number: 1869
  .....................................................
  </code></pre>
  
  <p>I have enabled ssl in server. I found lot of posts related to the same and followed them. But yet it is not sending email. </p>
  
  <p>Can anyone help me to fix this? Thanks in advance.</p>