I'm developing a website using cakephp 3.0 and I'm trying to send a confirmation email from my localhost (xampp) by using gmail server. I can tell for sure that my controller function is executed but nothing happen, no email, no error, no log, etc.
I read here that you can't send email from localhost (hence trying to use gmail to send it)
Here my config in the app.php
'EmailTransport' => [
'default' => [
'className' => 'Mail',
// The following keys are used in SMTP transports
'host' => 'smtp.gmail.com',
'port' => 587,
'timeout' => 30,
'username' => 'my_email@gmail.com',
'password' => 'password',
'client' => null,
'tls' => true,
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'my_email@gmail.com',
],
],
And here is my function where I try to send the email.
public function send()
{
$email = new Email('default');
$email->to('other_email@gmail')
->subject('About')
->message('blablabla');
if($email->send())
{
return $this->render('confirmation');
}
}
I can tell for sure this code is executed because the confirmation view is rendered after I press send.
What am I missing to send the email?