First create configuration file name as email.php inside app/config/email.php and setup different config options here.
public $default = array(
'transport' => 'Mail',
'from' => array('fromname@email.com' => 'kshitiz dixit'),
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
so it will set from name as kshitiz dixit and from email as froname@email.com.
Next to use CakeEmail in our application need to load the clas using app::uses in our controller or model.
App::uses('CakeEmail', 'Network/Email');
Next is to create object of CakeEmail class.
$Email = new CakeEmail();
$Email->from(array('fromname@email.com' => 'kshitiz dixit'));
$Email->to('abc@xyz.com', 'nameofrecipient');
To set subject and email body,
$Email->subject('my first cake email');
$Email->send('hello');
So send fucntion will send the email to recipient like this way we can send email in cakephp.
0 Comment(s)