title: How to send email in codeigniter 3
body: <p>I want to send email in codeigniter 3 but fail to do that i have set my smtp setup but not work is there any way to send email in codeingter 3 it google it several times but fail to solve it thanks in advance.
  this is my controller </p>
  
  <pre><code>$this-&gt;db-&gt;query("INSERT INTO newsletter_subscribers (name,email, status, date_created, date_updated) VALUES ('".$options['name']."','".$options['email']."', 'inactive', NOW(), NOW())");
  
  $this-&gt;session-&gt;set_userdata('newsletter_sess', $options['email']);
  
  $query = $this-&gt;db-&gt;query("select subject, html_body, text_body, allowed_vars from email_template where tempid = 12");
  
  if ($query-&gt;num_rows() &gt; 0){
      $objEmailTemplate = $query-&gt;row(); 
  }
  
  //%SITE_TITLE%, %SITE_URL%, %EMAIL%, %NAME%, %LINK_URL%
  $allowed_vars = explode(', ', $objEmailTemplate-&gt;allowed_vars);
  $rep_vars = array(site_url(), 
      SITE_NAME, $options['email'], 
      $options['email'],
      base_url().'front/subscribed/'.base64_encode($options['email']));
  
  $subject = str_replace($allowed_vars, $rep_vars, $objEmailTemplate-&gt;subject);
  $html_body = str_replace($allowed_vars, $rep_vars, $objEmailTemplate-&gt;html_body);
  $text_body = str_replace($allowed_vars, $rep_vars, $objEmailTemplate-&gt;text_body);
  
  $admin = $this-&gt;main_model-&gt;getSettingData('contact_email');
  $contact_email = $admin-&gt;value;
  
  // Configure email library
  $config['protocol'] = 'smtp';
  $config['smtp_host'] = 'ssl://ssmtp.gmail.com';
  $config['smtp_port'] = 465;
  $config['smtp_user'] = 'hussainshahid006@gmail.com';
  $config['smtp_pass'] = '******';
  $config['mailtype'] = 'html';
  
  // Load email library and passing configured values to email library 
  $this-&gt;load-&gt;library('email', $config);
  $this-&gt;email-&gt;set_newline("\r\n");
  
  $this-&gt;email-&gt;from($contact_email);
  $this-&gt;email-&gt;to($options['email']);
  $this-&gt;email-&gt;subject($subject);
  $this-&gt;email-&gt;message($html_body);
  $this-&gt;email-&gt;send();
  </code></pre>