I'm working in CakePHP 3.4
I have setup Mailer to send verification email to user after registration.
/src/Mailer/UserMailer.php
<?php
namespace App\Mailer;
use Cake\Mailer\Mailer;
class UserMailer extends Mailer
{
public function verify($user)
{
$this
->setProfile('no-reply')
->setTemplate('register')
->setLayout('authentication')
->setEmailFormat('html')
->setTo($user->email)
->setSubject('Verify Account')
->setViewVars(['name' => $user->first_name, 'email' => $user->email, 'hash' => $user->verification_hash]);
}
public function implementedEvents()
{
return [
'Model.afterSave' => 'onRegistration'
];
}
public function onRegistration(Event $event, EntityInterface $entity, ArrayObject $options)
{
if ($entity->isNew()) {
$this->send('verify', [$entity]);
}
}
}
But, it is not sending any email.
Emails are being sent when triggered manually from controller using
$this->getMailer('User')->send('verify', [$user]);