Cron & Shell -> Mail
Hi, here is my problem:
I send an email using a Shell which is done by a Cron job.
Nothing special, unless I'd like to use a template for my email where I send several variables using set() method.
This is how I do it:
App::import('Core', 'Controller');
App::import('Component', 'Email');
$this->Controller =& new Controller();
$this->Email =& new EmailComponent(null);
$this->Email->initialize($this->Controller);
$this->Email->charset = 'ISO-8859-1';
$this->Email->to = $winner['User']['email'];
$this->Email->subject = 'Félicitations!';
$this->Email->from = 'blabla <blabla@gmail.com>';
$this->Email->template = 'winner';
$this->Email->sendAs = 'html';
$this->set('winner', $winner);
$this->Email->send();
And Cron sends me back:
Fatal error: Call to undefined method WinnerShell::set()
Could anyone help me with this?
Asked by renardthis, on 11/6/10
1 Answer
<< previous next >>
Rating
0
Viewed
3285 times
Last Activity
on 12/6/10







I spend way too long last night trying to figure out how to send emails through a shell. These two resources helped me the most:
http://bakery.cakephp.org/articles/view/emailcomponent-in-a-cake-shell
http://osdir.com/ml/CakePHP/2009-06/msg00834.html
nleach - on 12/6/10