⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Callback after insert/update can not send email



Muhamad Sahib
  • profile picture
  • Member

Posted 01 July 2016 - 04:26 AM

Hello there,

 

Please help me...I have a function to sending an email after insert/update records...and somehow it doesnt work at all...

 

my code is here :

 

function product() {

 

...

$crud->callback_after_update(array($this, 'log_product_after_update'));

...

 

}

 

function log_product_after_update($post_array,$primary_key)
{
 
$this->load->library('email');
 
$config['mailtype'] = 'html';
$this->email->initialize($config);
 
$this->email->from('admin@xxx.com', 'XXX Admin');
$this->email->to('sahib.muhamad@yyy.com');
 
$this->email->subject('TEST');
$this->email->message('Update product');
 
$this->email->send();
 
return true;
}
 
anyone can help me?

 

 

 

 


Amit Shah
  • profile picture
  • Member

Posted 01 July 2016 - 05:26 AM

well.. what if you just killed the execution in the begining - like die or so.. dose it get executed - giving some error or so?? 


Muhamad Sahib
  • profile picture
  • Member

Posted 01 July 2016 - 06:34 AM

well.. what if you just killed the execution in the begining - like die or so.. dose it get executed - giving some error or so?? 

 

I've ediited my code :

 

function log_product_after_update($post_array,$primary_key)
{
   try {
 
         $this->load->library('email');
 
         $config['mailtype'] = 'html';
         $this->email->initialize($config);
 
         $this->email->from('admin@petodate.com', 'Peto Admin');
         $this->email->to('sahib.muhamad@gmail.com');
 
         $this->email->subject('TEST');
         $this->email->message('Update product 2');
 
         if (!$this->email->send()) {
               show_error($this->email->print_debugger()); }
          else {
               return true;
          }
}
catch(Exception $e){
        show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
 
 
And it shows nothing (always redirect to update success page)...
}

Amit Shah
  • profile picture
  • Member

Posted 01 July 2016 - 14:12 PM

Well... great - what i will e doing is first check if the same function is reached or not.. hence in the begining of the funtion call - i will just kill the application (die with some message) ...

that way make sure 1st if the same actually reaches or not..

secondly .. 1ce something like this is done - we need to check the output back in the console.!! ( chrome / firefox console )