Skip to content
Advertisement

Why CI library not sending email neither showing error

I am trying to send Email through Codeigniter Email library following is my setup `

           $config['protocol']    = 'smtp';
           $config['smtp_host']    = 'ssl://smtp.gmail.com';
           $config['smtp_port']    = '465';
           $config['smtp_timeout'] = '60';
           $config['smtp_user']    = 'zahoorulhaq37@gmail.com';
           $config['smtp_pass']    = '****';
           $config['charset']    = 'utf-8';
           $config['newline']    = 'rn';
           $config['mailtype'] = 'html';
       
           $config['validation'] = TRUE;
           // bool whether to validate email or not

           $this->email->initialize( $config );
           $this->email->from( 'zahoorulhaq37@gmail.com' );
           $this->email->to( 'zahoorulhaq37@hotmail.com' );
           $this->email->subject( 'testing' );
           $this->email->message( 'testingg' );
           $sent =  $this->email->send();
          if ( !$sent ) {
             echo $this->email->print_debugger();
                }
                 echo $sent;`

But it just timeouts and I get neither the response which should be true and neither gets an error

Advertisement

Answer

To show the error in your email library you must set the send method to false like so:

$this->email->send(false);

Then the debugger will work. Otherwise the debugger has nothing to show.

echo echo $this->email->print_debugger();

Also if you’re sending email with smtp with ssl you might need an additional config.

$config['smtp_crypto'] = 'ssl';
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement