Please note that the method differs depending on the version of CakePHP.
The following is the case for CakePHP 2.x:
The CakeEmail class includes the following methods:
CakeEmail::helpers()
This allows you to use a group of helpers in the .ctp file in the body of the mail.
The following is an example.
App::uses('CakeEmail', 'Network/Email');
$mail_address='[email protected]';
$cakeEmail=newCakeEmail();
$mailResponse=$email->config('default')
->helpers('Html')//← Load HTML helper
->viewVars(array('address'=>$mail_address))
->to($mail_address);
try
{
$cakeEmail->send();
}
catch(Exception$e)
{
// exception handling
}
© 2024 OneMinuteCode. All rights reserved.