Cake 2 – CakeMail

CakeMail replaces the previous EmailComponent. So now we do this instead.

  • Don’t set your view variables using set() anymore, use ->viewVars.
  • Make sure you instantiate the class App::uses(‘CakeEmail’, ‘Network/Email’); in the top of your class.
  • It also works from anywhere, and you can load helpers which is great.
  • More info here. I really like it ;)

$email = new CakeEmail();
$email->from(array(Configure::read('Site.email') => Configure::read('Site.title')))
->to((Configure::read('Config.debug')) ? Configure::read('Site.email') : $user['User']['email'])
->subject('[' . Configure::read('Site.title') . '] ' . __('Reset Password'))
->viewVars(array(
'user' => $user,
'activationKey' => $activationKey))
->template('forgot_password');

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>