Reputation: 73
I want the url will be available in Email\html\forgot_password_email.ctp
method in controller
public function forgotPassword(){
$url = Router::url(['controller' => 'users', 'action' => 'reset'], true) . '/' . $passkey;
$this->getMailer('User')->send('forgotPassword', [$user]);
}
UserMailer.php
->to($user->email)
->emailFormat('html')
->subject(sprintf('Forgot Password link %s', $user->username))
->viewVars([
'username'=> $user->username,
'useremail'=>$user->email,
'userid' => $user->id
])
->template('forgotPasswordEmail')
I can print this 3 variables such as username,useremail,userid in Email\html\forgot_password_email.ctp but I dont know how to print the url
Upvotes: 0
Views: 58
Reputation: 25698
It seems that you copy and pasted but didn't read or understood what is explained on this page in the manual.
The 2nd arg of send() is an array that takes the args that are passed to your mailer function. So just pass the URL there. Or even better, because this doesn't belongs into the controller (remember: fat model, skinny controller): Generate the URL in the template and pass the token.
Upvotes: 1