【发布时间】:2019-01-21 17:14:41
【问题描述】:
我正在尝试使用 Laravel (5.4) 发送电子邮件,但仍然收到此错误:
FileViewFinder.php 第 137 行中的 InvalidArgumentException:
查看 [mails.forgot] 未找到。
在 FileViewFinder->findInPaths('mails.forgot', array('{my app dir}/resources/views'))
在 FileViewFinder.php 第 79 行
在 FileViewFinder->find('mails.forgot')
在 Factory.php 第 128 行
在 Factory->make('mails.forgot', array('emailAddress' => null, 'connection' => null, 'queue' => null, 'delay' => null, 'message' => object(Message )))
在 Mailer.php 第 286 行
将文件添加到resources/views/mails/forgot.blade.php
在控制器中:
Mail::to('test@gmail.com')->send(new ForgotEmail());
在邮件文件(Mail/ForgotEmail.php)中我调用:
return $this->view('mails.forgot');
对于我的其余应用程序视图都正常工作。
【问题讨论】:
-
你有没有运行 composer dump-autoload 看看这是否有帮助?
-
能否手动查看
mails.forget,就像在Route中一样,比如Route::get("/test", function(){ return view("mails.forgot"); });,然后导航到myapp.com/test -
dump-autoload 没有帮助.. @TimLewis 不错的提示,这给了我同样的错误.. 所以看来原因不是可邮寄的。
-
我的路由通常是这样的:Route::post('register/confirm', 'UserController@sendConfirmationEmail');
-
是的;路由应该使用控制器方法,但为了快速参考,您可以使用
function来模仿一个。是的,如果你不能手动返回它,还有别的东西,但是,乍一看,我看不到它。mails.forgot似乎是访问它的正确密钥...