Jump to content


Callback after insert/update can not send email

callback update insert email

  • Please log in to reply
3 replies to this topic

#1 Muhamad Sahib

Muhamad Sahib

    Newbie

  • Members
  • Pip
  • 3 posts

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?

 

 

 

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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?? 



#3 Muhamad Sahib

Muhamad Sahib

    Newbie

  • Members
  • Pip
  • 3 posts

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)...
}


#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 01 July 2016 - 02: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 )







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users