AllToolKits.com Posted June 5, 2015 Report Posted June 5, 2015 I created a plugin, in that i wrote public function getEvents() { return array( array( 'event' => "Invoices.edit", 'callback' => array("this", "mailme") ) // Add multiple events here ); } and function mailme as below public function mailme($event) { // This will execute when the "Appcontroller.preAction" event is triggered mail("me@mydomain.com", "invoice edit", "An invoice is editted!!!"); } But i am not getting any email when an editting. Why it will be so? I logged in as admin and editted some invoices and no email yet in my inbox. Quote
Blesta Addons Posted June 5, 2015 Report Posted June 5, 2015 have you tested if mail function work in standalone ? and to be sure the event is working, try to print_r() something . also why not to use the inernal mail class ? Quote
Blesta Addons Posted June 5, 2015 Report Posted June 5, 2015 i have forget to tell you the model is "Emails" and the function is "sendCustom" so the function will be like this public function mailme($event) { // This will execute when the "Appcontroller.preAction" event is triggered Loader::loadModels($this, array("Emails")); $params = $event->getParams(); $invoice_id = $params['invoice_id']; // $from = "me@mydomain.com" ; // you can fetch the blesta email also $from_name ="Your company name "; // you can fetch the blesta email also $to = "youremail@domain.com"; $subject = "invoice edit"; $body = array(); //$body['html'] = "Your html content"; $body['text'] = "the invoice ". $invoice_id ." has been editted!!!"; $this->Emails->sendCustom($from, $from_name, $to, $subject, array $body, array $tags=null, $cc=null, $bcc=null, array $attachments=null, array $options=null); } Quote
AllToolKits.com Posted June 5, 2015 Author Report Posted June 5, 2015 My aim was not send an email, i just want to know weather the event is working or not.I added your code. after invoice edit even now no mail was sent.Is there any other wahy to know wetaher the event is working or not? Quote
Tyson Posted June 5, 2015 Report Posted June 5, 2015 It is not enough to simply add an event in Plugin::getEvents(). The events need to be registered in Blesta. This only happens when the plugin is installed or upgraded. You should update the plugin's version so that it can be upgraded to register the events. Quote
AllToolKits.com Posted June 5, 2015 Author Report Posted June 5, 2015 Tyson and naja7host, thanks for your answers. It worked well now I had to uninstall and then install plugin to work code changes. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.