【问题标题】:Invalid view. Send email - Laravel - 5.8无效的视图。发送电子邮件 - Laravel - 5.8
【发布时间】:2019-06-28 18:52:28
【问题描述】:

我正在尝试使用 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,

我确信我有这种看法。我可以用一些方法控制器返回它。

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案1】:

    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);
    

    欲了解更多信息:https://laravel.com/docs/5.8/mail#sending-mail

    【讨论】:

      猜你喜欢
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 1970-01-01
      • 1970-01-01
      • 2019-06-24
      • 2018-07-08
      • 1970-01-01
      相关资源
      最近更新 更多