I want to send email activation to every user after sign up. But the email did not send to gmail. please help.
this is email.php:
public $smtp = array(
'transport' => 'Smtp',
'from' => array('****@gmail.com' => 'Virlen'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 300,
'username' => '****@gmail.com',
'password' => '****',
'client' => null,
'log' => false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
This is app controller:
public function __sendMail($To, $Subject, $message, $From, $template = 'default', $smtp = 1, $attachment = array() ) {
App::uses('CakeEmail', 'Network/Email');
// echo $smtp;die;
$email = new CakeEmail();
$email->config();
$email->to($To);
$email->from($From);
$email->subject($Subject);
$email->emailFormat('html');
$email->attachments($attachment) ;
$email->template($template);
$email->layout = 'default';
//$smtp = 1;
/* if ($smtp == 1) {
$EmailConfig->smtpOptions = array(
'port' => 465,
'timeout' => 300,
'host' => 'ssl://smtp.gmail.com',
'username' => 'test@gmail.com',
'password' => 'test@123',
'transport' => 'Smtp'
);
$EmailConfig->delivery = 'smtp';
} */
// unset($this->helpers['Paginator']);
if ($email->send($message)) {
return true;
} else {
return false;
}
}