Hi, I’m trying to send a simple email upon user registration. It seems that I’m following the documentation correctly, yet I do not receive the email.
https://book.cakephp.org/3/en/core-libraries/email.html
use Cake\Mailer\Email;
class UsersController extends AppController
{
public function register(){
$user = $this->Users->newEntity();
if($this->request->is('post')){
$user = $this->Users->patchEntity($user, $this->request->getData());
if($this->Users->save($user)){
$this->Flash->success('You are registered and can login');
// Send email
$email = new Email('default');
$email->setFrom(['testAdmin@xtra.co.nz' => 'Bargin Books'])
->setTo('test123@xtra.co.nz')
->setSubject('Registration')
->send('Welcome to Bargin Books');
return $this->redirect(['action' => 'login']);
}else{
$this->Flash->error('You are not registered');
}
}
$this->set(compact('user')); //users?
$this->set('_serialzie', ['user']);
}
}
I appreciate your help