Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How do I send emails from AppController? (CakePHP 2.0)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
WhyNotSmile  
View profile  
 More options May 18 2012, 7:08 am
From: WhyNotSmile <sharongilmor...@gmail.com>
Date: Fri, 18 May 2012 04:08:51 -0700 (PDT)
Local: Fri, May 18 2012 7:08 am
Subject: How do I send emails from AppController? (CakePHP 2.0)

I've been sending emails from my PagesController, and that has been working
fine, but now I need to send from AppController instead, and I can't get
the emails to send.  As far as I can see, I have exactly the same code in
both, but the AppController function simply doesn't send the email.  There
are no error messages or anything - I just don't get an email.

I wondered if maybe it can't find the view file or something like that?  
Can anyone advise me?

Here is my code (in AppController):

    function sendSystemEmail($to = EMAIL_CONTACT, $from = array(EMAIL_FROM

> => SITE_NAME), $subject = null, $body = null, $view = null, $vars = null) {
>         App::uses('CakeEmail', 'Network/Email');
>         $email = new CakeEmail();
>         $email->viewVars(array(
>                 'body' => $body,
>                 'vars' => $vars
>         ));
>         $email->template($view)
>                 ->emailFormat('html')
>                 ->from(EMAIL_FROM)
>                 ->to($to)
>                 ->subject($subject)
>                 ->send();
>         return;
>     }

Thanks for any help you can give!

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.