title: How do I send email from AppController in CakePHP 2.0?
body: <p>I'm trying to send an email from <code>AppController</code> in my CakePHP 2.0 app.  It works fine if I send it from the <code>PagesController</code>, but I need to be able to send from <code>AppController</code> as well.</p>
  
  <p>I have:</p>
  
  <pre><code>function sendSystemEmail($to = EMAIL_CONTACT, $from = EMAIL_FROM, $subject = null, $body = null, $view = null, $vars = null) {
      App::uses('CakeEmail', 'Network/Email');
      $email = new CakeEmail();
      $email-&gt;viewVars(array(
              'body' =&gt; $body,
              'vars' =&gt; $vars
      ));
      $email-&gt;template($view)
              -&gt;emailFormat('html')
              -&gt;from($from)
              -&gt;to($to)
              -&gt;subject($subject)
              -&gt;send();
      return;
  }
  </code></pre>
  
  <p>When I use this, I don't get any errors, but the email doesn't arrive.  I can't see that there's any different between this and the code I have in <code>PagesController</code>, so I'm assuming that there's something that <code>AppController</code> doesn't have access to maybe?  I can't figure out what though!</p>