Hi Guys,
i'm implementing a feature for a REST webapp. I would like to send an email to all the Members of a certain group based on some logic. This has to happen every day so i need cronjobs. It is an app for an hospital where people with OCD can practise their exercises at home. Based on their therapy they need to do a certain amount of exercises a week. So i would like to send them email reminders. i can hardly find any examples so i hope you guys could help me. Please let me know if this is the right way to do this:
here's my EmailTask.
class EmailTask extends BuildTask {
protected $title = 'Email patients';
protected $description = 'A task that emails patients exercises';
protected $enabled = true;
function run($request) {
Patient_Controller::init();
}
}
Here's the controller i'am calling:
class Patient_Controller extends Controller {
private static $allowed_actions = array('email');
public function email() {
$email = new Email();
$email->setTo($this->Email);
$email->setSubject('test');
$email->setFrom('no_reply@mysite.com');
$email->setTemplate('EmailReminder');
$email->send();
}
}
i keep getting this error: [Strict Notice] Non-static method Patient_Controller::email() should not be called statically, assuming $this from incompatible context.
The other question is, do i need to put the logic in my buildtask (looping over al the patients and send them their email) or is this the right way to do it?