I have a very simple model. I want to add a send email routine to on of the methods for the model:
$this->Email->delivery = 'smtp'; $this->Email->template = 'default'; $this->Email->sendAs = 'text'; $this->Email->from = 'email'; $this->Email->to = 'email'; $this->Email->subject = 'Error';
I’ve tried putting
App::import('Component', 'Email');
at the top, to no avail. The error I get is:
Fatal error: Call to undefined method stdClass::send() in E:\xampp\htdocs8080\app\models\debug.php on line 23
Any ideas?
I’m running CakePHP 1.2
Well, you’re doing it wrong way. You should place email send routine in your AppController:
Then use it from ANY controller like this:
And don’t forget to place
in controllers, in which you ‘re using _sendMail function.