2016-08-02 135 views
0

我按照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,因爲我的代碼與類相同。

+0

這是什麼時候發生的?新用戶註冊時或未激活用戶嘗試登錄時? – Makan

+0

當新用戶註冊時。儘管拋出錯誤,它仍然會進入SQL數據庫。 – omrakhur

+0

在ActivationService類的構造函數中,您是否按照教程中的說明初始化activationRepo?問題是shouldSend()函數中的$ this-> acticationRepo爲null。這是應該解決的問題。 – Makan

回答

-1

嘗試添加使用App \ ActivationRepository;在ActivationService下使用Illuminate \ Mail \ Message;

問題似乎是$ this-> activationRepo爲null,而不是ActivationRepository的實例;

+1

ActivationRepository和ActivationService類都在相同的命名空間下。不需要添加「使用...」。 – Makan

+0

我同意@Makan在這裏 – omrakhur