title: Sending Email using SMTP gmail in CodeIgniter from website
body: <p>I'm stuck on my problem to send email with codeigniter. </p>
  
  <p>I've already done successful sending gmail, but the problem is the recipient and the sender are the same. I want this email received to me from sender in website,</p>
  
  <p>There is my <strong>Controller</strong> :</p>
  
  <pre><code>public function index(){        
      $this-&gt;sendEmail(); 
      $this-&gt;load-&gt;view('content_contact');
  }
  public function sendEmail(){
      $this-&gt;load-&gt;helper(array('form', 'url'));
      $this-&gt;load-&gt;library('email');
  
      //konfigurasi email
      $config = array();
      $config['charset'] = 'utf-8';
      $config['useragent'] = 'Codeigniter';
      $config['protocol']= "smtp";
      $config['mailtype']= "html";
      $config['smtp_host']= "ssl://smtp.gmail.com";
      $config['smtp_port']= 465;
      $config['smtp_timeout']= "5";
      $config['smtp_user']= "my_email$gmail.com";
      $config['smtp_pass']= "my_pass";            
      $config['crlf']="\r\n";
      $config['newline']="\r\n";
  
      $config['wordwrap'] = TRUE;
      $this-&gt;load-&gt;view('content_contact');
  
      $this-&gt;email-&gt;initialize($config);
      $this-&gt;email-&gt;from($this-&gt;input-&gt;post('from'));
      $this-&gt;email-&gt;to("my_email@gmail.com");
      $this-&gt;email-&gt;subject($this-&gt;input-&gt;post('subject'));
      $this-&gt;email-&gt;message($this-&gt;input-&gt;post('isi'));
  
      if($this-&gt;email-&gt;send()){
          echo "pengiriman email Success";
      }
      else{
          echo "pengiriman email Failed";
      }
  
  }
  </code></pre>
  
  <p>And This is my <strong>View</strong> : <code>content_contact.php</code>
  <a href="https://i.stack.imgur.com/udeZS.png" rel="nofollow noreferrer">content_contact.php</a></p>