发送邮箱验证提示有效时间,会更友好
将邮箱验证有效时间添加到邮件内容会更友好
app/Notifications/EmailVerificationNotification.php
public function toMail($notifiable)
{
// 使用 Laravel 内置的 Str 类生成随机字符串的函数,参数就是要生成的字符串长度
$token=Str::random(16);
// 往缓存中写入这个随机字符串,有效时间为 30 分钟。
Cache::set('email_verification_'.$notifiable->email,$token,30);
$url=route('email_verification.verify',['email' => $notifiable->email,'token' => $token]);
return (new MailMessage)->greeting($notifiable->name.'您好:')
->subject('注册成功,请验证您的邮箱')
->line('请点击下方链接验证您的邮箱,有效时间30分钟')
->action('验证', url($url));
}
推荐文章: