I think you are getting a little confused between controller and
components. Your simplemail function could be placed inside the
'Email' component. And you could use the simplemail function in other
controllers by importing the component (and not the controller)
App::import('Component','Email')

You could treat components as controller helper classes (although they
do more than than that).

_k10_

On Jan 20, 1:25 am, gerhardsletten <[email protected]> wrote:
> Writing an app where I was planing to move all email delivering in one
> controller. When I try to load this "Utility" controller in a function
> from another controller. App::import fail to load Email component in
> this controller
>
> Controller 1:
> <code>
> function send_message() {
> ...
> App::import('Controller', 'Main');
> $main = new MainController;
> $main->simplemail($to, $subject, $body);}
>
> </code>
>
> Utility controller:
> <code>
> class MainController extends AppController {
>
> var $name = 'Main';
> var $components = array('Email');
> var $uses = null;
> ...
> function simplemail($to, $subject, $body) {
>                 $mail_settings = Configure::read('Mail');
>                 $this->Email->from    = $mail_settings['from_name'] . ' <' .
> $mail_settings['from_mail'] . '>';
>                 $this->Email->to      = $to;
>                 $this->Email->subject = $subject;
>                 debug($this->Email);
>                 //$this->Email->send($body);
>
>         }
>
> </code>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to