我按照this site上的教程来帮助我为新用户构建电子邮件验证。根据代码Laravel 5.2电子邮件验证错误
Route::auth();
Route::get('user/activation/{token}', 'Auth\[email protected]')->name('user.activate');
Route::get('/', '[email protected]');
Route::get('auth/logout', 'Auth\[email protected]');
Route::get('/home', '[email protected]');
这里是.ENV文件
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_FROM=*from address given by mailgun*
MAIL_NAME=CompanyName
MAIL_PORT=587
MAIL_USERNAME=*Mailgun username*
MAIL_PASSWORD=*Mailgun password*
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=*mailgun domain*
MAILGUN_SECRET=*secret key*
其他一切已经做到: 我不断收到错误:
FatalErrorException in ActivationService.php line 66:
Call to a member function getActivation() on null
这里是routes.php文件在教程中给出。请参考代码there,因为我的代码与类相同。
这是什么时候发生的?新用户注册时或未激活用户尝试登录时? – Makan
当新用户注册时。尽管抛出错误,它仍然会进入SQL数据库。 – omrakhur
在ActivationService类的构造函数中,您是否按照教程中的说明初始化activationRepo?问题是shouldSend()函数中的$ this-> acticationRepo为null。这是应该解决的问题。 – Makan