laravel 开启邮件验证

暂无标签

1.配置smtp邮箱服务器,根目录.env文件

MAIL_DRIVER=smtp
MAIL_HOST=邮件服务器地址
MAIL_PORT=邮件服务器端口
MAIL_FROM_ADDRESS=邮箱地址
MAIL_USERNAME=邮箱地址
MAIL_PASSWORD=邮箱密码
MAIL_ENCRYPTION=ssl

2.路由

Auth::routes();
改为
Auth::routes(['verify' => true]);

3.需要验证邮箱才能访问的路由,后面加

->middleware('verified')

4.模型User.php

class User extends Authenticatable
改为
class User extends Authenticatable implements MustVerifyEmail