Jump to content

Recommended Posts

Posted

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.

 

Posted

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);
}
Posted

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?

Posted

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.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...