php - 无效的视图。发送电子邮件 - Laravel - 5.8
问题描述
我正在尝试使用 Laravel 发送电子邮件。我在文件夹中有一个视图:views/emails/user.blade.php
使用简单的 HTML。
我创建了 Mailable: php artisan make:mail UserEmail
。在我发送电子邮件的控制器中:
Mail::send($request->user())
->queue(new PropertyAsk());
可邮寄:
public function build()
{
return $this->from('some email')
->view('emails.user');
}
,但是当我尝试时它说:
"message": "Invalid view.", "exception": "InvalidArgumentException", "file": "...vendor/laravel/framework/src/Illuminate/Mail/Mailer.php", "line": 310,
我确信我有这种看法。我可以用一些方法控制器返回它。
解决方案
该send
方法需要一个可邮寄的。
/**
* Send a new message using a view.
*
* @param string|array|\Illuminate\Contracts\Mail\Mailable $view
* @param array $data
* @param \Closure|string $callback
* @return void
*/
public function send($view, array $data = [], $callback = null)
但是,您传递给它一个App\User
. 您可以像这样更改它:
Mail::to($request->user())
->send(new UserEmail)
->queue(new PropertyAsk);
推荐阅读
- excel - 删除行的 VBA 代码仅删除第一行
- visual-c++ - 即使定义了未解析的符号,链接器错误 lnk2001
- bash - 关于 $(...) 和 bash 中的引号的问题
- visual-studio - Visual Studio 重复快捷方式不起作用
- python - %load_ext rpy2.ipython 出错:“CompiledFFI”对象没有属性“ffi”
- python - 用于检查字符串中是否存在不匹配元音的 Python 函数
- python - Ajax 函数未在 django 中显示值
- sql-server - 返回当前和上一年的记录,其中年份在 Acumatica 报告的 WHERE 子句中传递
- typescript - 如何仅使用 TypeScript 中的类型来导入已经可用的模块?
- python - Microsoft Azure IoT Python SDK 可以成功预配但不能使用相同的凭据连接