title: Sending email in CodeIgniter not working
body: <p>I am trying to send email using SMTP in CodeIgniter but it is not working. The code is as follows:</p>
  
  <pre><code>public function sendMail(){
      $config = array(
          'protocol'=&gt;'smtp',
          'smtp_host'=&gt;'ssl://smtp.gmail.com',
          'smtp_port'=&gt;465,
          'smtp_user'=&gt;'********@gmail.com',
          'smtp_pass'=&gt;'*********',
          'mailpath'=&gt; "/usr/sbin/sendmail",
          'mailtype'=&gt;'html',
          'charset'   =&gt; 'utf-8',
          'send_multipart'=&gt;FALSE
      );
  
      $this-&gt;load-&gt;library('email',$config);
      $this-&gt;email-&gt;initialize($config);
      $this-&gt;email-&gt;set_newline("\r\n");
      $this-&gt;load-&gt;library('encrypt',$config);
  
      $this-&gt;email-&gt;from('******@gmail.com');
      $this-&gt;email-&gt;to('******@gmail.com');
      $this-&gt;email-&gt;cc('******@gmail.com');
      $this-&gt;email-&gt;subject('Email Test');
      $this-&gt;email-&gt;message('Testing the email class.');
  
      if($this-&gt;email-&gt;send()){
          echo "Email sent success";
      }else{
          show_error($this-&gt;email-&gt;print_debugger());
      }
  }
  </code></pre>
  
  <p>I tried almost everything I found in the internet especially previous stack questions, but nothing seems to work. I am getting the usual error.</p>
  
  <h2>Severity: Warning Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (No connection could be made because the target machine actively refused it. )</h2>
  
  <p><strong>Filename: libraries/Email.php
  Line Number: 2023
  The following SMTP error was encountered: 10061 No connection could be made because the target machine actively refused it.
  Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.</strong></p>