I am using cakephp 2.1 and I wanna send an email to user.
So the code I used is below.
App::uses('CakeEmail', 'Network/Email');
public function sendMail($to, $subject, $data) {
// Set the Params
$email = new CakeEmail('default');
$email->from(array('admin@admin.com' => 'Admin'));
$email->emailFormat('text');
$email->to($to);
$email->subject($subject);
// Send Email
if($email->send($data)) {
return true;
} else {
return false;
}
}
This function returns true but I am not getting an email.Please suggest me where i am going wrong. Advance Thanks for your help.
Could be a myriad of reasons. Check the configuration settings in app/Config/email.php. You’ll need an SMTP server to relay your email.