【问题标题】:View not found for sending email with laravel 5.4未找到使用 laravel 5.4 发送电子邮件的视图
【发布时间】: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 似乎是访问它的正确密钥...

标签: php laravel email


【解决方案1】:

通过发出 php artisan cache:clearphp artisan config:cache 来清理 Laravel 缓存,看看是否可行...

【讨论】:

  • 解决了我的问题!我已经在本地执行了命令,但没有生效。必须直接在我的 vagrant box 上运行它。现在它可以工作了:)
  • @Dennis 很高兴它成功了,请选择我的答案作为接受的答案:)
【解决方案2】:

在我的具体情况下,我的模板文件名是user.new.blade.php

这是行不通的。我将它重命名为usernew.blade.php,现在它可以工作了。似乎文件名中不能有多余的点

【讨论】:

    猜你喜欢
    • 2018-02-01
    • 1970-01-01
    • 2019-03-12
    • 1970-01-01
    • 2017-07-02
    • 2017-11-24
    • 1970-01-01
    • 2020-06-02
    • 2018-04-20
    相关资源
    最近更新 更多