![](/img/trans.png)
[英]unable to send token and email value in mail using phpmailer for forgot password
[英]Add email next to token in Laravel forgot password template email link
我正在使用带有身份验证系统的 Laravel 8.5。 当用户想要更改密码时,它会发送带有链接的 email。 默认 email 包含如下所示的链接:
http://mywebsite/api/forgot-password?token=2ccece360b031db4dcadea0cbdf8dd47a1712632b727487a7226f19f8f607cc7&email=MyEmail%40gmail.com
我在 email 模板中做了一些更改。 在ResetPasswordNotification.php
我添加了这个:
public function toMail($notifiable)
{
return (new MailMessage)
->subject('MyApp password reset')
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', $this->url)
->line('This password reset link will expire in 60 minutes.')
->line('If you did not request a password reset, no further action is required.');
}
在User.php
中我有:
public function sendPasswordResetNotification($token)
{
$url = 'http://mywebsite/en/change-password?token=' . $token;
$this->notify(new ResetPasswordNotification($url));
}
现在我收到了这个链接:
http://mywebsite/en/change-password?token=8f87fc2d504507as385b4c47cb015cee4192749d3f1d641863524d513abb2a39
它只包含令牌而不包含 email。我如何将 email 添加到此,使其看起来像这样:
http://mywebsite/en/change-password?token=8f87fc2d504507as385b4c47cb015cee4192749d3f1d641863524d513abb2a39&email=UserEmail@gmail.com
尝试将 email 传递给 url。
public function sendPasswordResetNotification($token)
{
$url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' .$this->email;
$this->notify(new ResetPasswordNotification($url));
}
只需在$token
旁边添加$this->email
。
public function sendPasswordResetNotification($token)
{
$url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' . $this->email;
$this->notify(new ResetPasswordNotification($url));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.