I am attempting to make a method that sends out an HTML based email
but I am having some problems. In my App_Controller file I have:

function __sendEmailNotification($to,$from,$subject,$body) {

        App::import("Component","Email");
        $this->Email = new EmailComponent();

        $this->Email->to = $to;
        $this->Email->from = $from;
        $this->Email->subject = $subject;
        $this->Email->template = "email_notification";
        $this->Email->sendAs = "html";
        $this->set("email_body",$body);

        return $this->Email->send();

}

I have put this in the app_controller so I can call it from multiple
controllers but when I attempt to do something like:

$this->__sendEmailNotification
("some...@email.com","u...@us.com","Subject here","body of the email");

I get the following errors:

Notice (8): Undefined property: EmailComponent::$Controller [CORE/cake/
libs/controller/components/email.php, line 352]
Notice (8): Trying to get property of non-object [CORE/cake/libs/
controller/components/email.php, line 352]
Notice (8): Undefined property: EmailComponent::$Controller [CORE/cake/
libs/controller/components/email.php, line 359]
Notice (8): Trying to get property of non-object [CORE/cake/libs/
controller/components/email.php, line 359]
Notice (8): Undefined property: View::$webroot [CORE/cake/libs/view/
view.php, line 751]

The email is delivered but I get:

Notice (8): Undefined variable: body [APP/views/elements/email/html/
email_notification.ctp, line 1]

Any Ideas on how to fix this? Any help is appreciated as always!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to