title: CodeIgniter throws "Message: Call to a member function initialize() on null"
body: <p><strong>welcome.php file</strong>  </p>
  
  <pre><code>  function formData(){
          if (empty($this-&gt;input-&gt;post('checkprocess'))) {
                          $email_config = Array(
                              'mailtype' =&gt; 'html',
                              'charset' =&gt; 'iso-8859-1'
                          );
  
                          $admin_email ='rockpokhrel@gmail.com';
                          $name = $this-&gt;input-&gt;post('full_name');
                          $email = $this-&gt;input-&gt;post('email');
                          $message = "Dear Admin, &lt;br/&gt;" .
                          "Contact Information of Users:" .'&lt;br/&gt;'.
                          "&lt;b&gt;Name&lt;/b&gt; :- " . $this-&gt;input-&gt;post('full_name') .'&lt;br/&gt;'.
                          "&lt;b&gt;Email:-&lt;/b&gt; " . $this-&gt;input-&gt;post('email') .'&lt;br/&gt;'.
                          "&lt;b&gt;Contact Number:-&lt;/b&gt; " . $this-&gt;input-&gt;post('mob_num') .'&lt;br/&gt;'.'&lt;br/&gt;'.
                          "&lt;b&gt;Address:-&lt;/b&gt; " . $this-&gt;input-&gt;post('address') .'&lt;br/&gt;'.'&lt;br/&gt;'.
                          "&lt;b&gt;Message:-&lt;/b&gt; " . $this-&gt;input-&gt;post('message');
                          $this-&gt;load-&gt;library('email', $email_config);
                          $this-&gt;email-&gt;set_newline("\r\n");
                          $this-&gt;email-&gt;from($this-&gt;input-&gt;post('email'), $this-&gt;input-&gt;post('name'));
                          $this-&gt;email-&gt;to($admin_email);
                          $this-&gt;email-&gt;subject("Public Contact/Feedback");
                          $this-&gt;email-&gt;message($message);
  
                          if ($this-&gt;email-&gt;send()) {
                          echo "&lt;meta http-equiv=REFRESH CONTENT=0;url='".base_url()."'&gt;";exit();
  
                          $this-&gt;db-&gt;insert('tbl_contactusform',$email_config);
                                      redirect(base_url());
                              }
      }
  }
  </code></pre>
  
  <p><strong>library/email.php file</strong></p>
  
  <pre><code>&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
  
  $config = array(
      'protocol'  =&gt; 'smtp',
      'smtp_host' =&gt; 'ssl://smtp.example.com',
      'smtp_port' =&gt; 465,
      'smtp_user' =&gt; '**********@gmail.com',
      'smtp_pass' =&gt; '************',
      'mailtype'  =&gt; 'html',
      'charset'   =&gt; 'utf-8'
  );
  $this-&gt;email-&gt;initialize($config);
  $this-&gt;email-&gt;set_mailtype("html");
  $this-&gt;email-&gt;set_newline("\r\n");
  
  $htmlContent = '&lt;h1&gt;Sending email via SMTP server&lt;/h1&gt;';
  $htmlContent .= '&lt;p&gt;This email has sent via SMTP server from CodeIgniter application.&lt;/p&gt;';
  
  $this-&gt;email-&gt;to('**********@gmail.com');
  $this-&gt;email-&gt;from('**********@gmail.com','MyWebsite');
  $this-&gt;email-&gt;subject('How to send email via SMTP server in CodeIgniter');
  $this-&gt;email-&gt;message($htmlContent);
  
  
  $this-&gt;email-&gt;send();
  </code></pre>
  
  <p>I want to add email feature in website but I get this stack trace: </p>
  
  <blockquote>
    <p>A PHP Error was encountered Severity: Notice</p>
    
    <p>Message: Undefined property: Welcome::$email</p>
    
    <p>Filename: MX/Loader.php</p>
    
    <p>Line Number: 304</p>
    
    <p>Backtrace: </p>
    
    <p>error and </p>
    
    <p>An uncaught Exception was encountered Type: Error</p>
    
    <p>Message: Call to a member function initialize() on null</p>
    
    <p>Filename: E:\xampp\htdocs\website\application\libraries\email.php</p>
    
    <p>Line Number: 17</p>
  </blockquote>
  
  <p>I am a beginner in CodeIgniter.</p>