I'm on Cakephp 2.4.5, How do i make use of / import CakeEmail functions so i can use them in my Shell script? I've searched everywhere but can't find an answer. Most examples talk about sending an email from a Controller but not a Shell.
This Shell is executed by a Cron job.
I've tried the following:
class EmailShell extends AppShell {
//App::uses('CakeEmail', 'Network/Email'); ///Results in Error: Parse error: syntax error, unexpected 'App' (T_STRING),
//App::import('Component', 'Email'); //Results in Error: Parse error: syntax error, unexpected 'App' (T_STRING),
$tasks = array('Email'); //Results in Error: [0m Task class EmailTask could not be found.
public function main () {
//email sending logic here
}
App::uses statements need to be above the class start:
App::uses('CakeEmail', 'Network/Email');
class EmailShell ...
Then you can use it anywhere in this file class:
$Email = new CakeEmail();
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With