Is it possible to log emails sent using CakeEmail using the new (2.1+) Events system?
I'm hoping I can do something like this, only what I have doesn't do anything yet:
// config/bootstrap.php
App::uses('CakeEmailRecord', 'Lib/Event');
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach(new CakeEmailRecord());
// /app/Lib/Event/CakeEmailRecord.php
App::uses('CakeEventListener', 'Event');
class CakeEmailRecord implements CakeEventListener {
public function implementedEvents() {
return array(
'Network.CakeEmail.afterSend' => 'recordSend',
);
}
public function recordSend($event) {
$this->log("triggered an event");
}
}
I'm specifically asking about the events system here. I want to know if that feature is something I can & should use to solve this. The question tagged as a duplicate does not deal with the cake events system