【问题标题】:Sending mails with no data on Laravel在 Laravel 上发送没有数据的邮件
【发布时间】:2015-12-29 01:10:34
【问题描述】:

我明白了:

Mail::send('emails.orders.attach', null, function($message) use($mail, $subject) {
        $message->from(Config::get('mail.from["address"]'), Config::get('mail.from["name"]'))
            ->to($mail, 'Sender name here')
            ->subject($subject);
    });

laravel 告诉我:

 Argument 2 passed to Illuminate\Mail\Mailer::send() must be of the type array, null given

我不需要发送数据,我的电子邮件模板不发送数据,除了一个包含客户所有数据的附件。

【问题讨论】:

    标签: php email laravel


    【解决方案1】:

    只传递一个空数组

    Mail::send('emails.orders.attach', [], function($message) use($mail, $subject) {
        $message->from(Config::get('mail.from["address"]'), Config::get('mail.from["name"]'))
            ->to($mail, 'Sender name here')
            ->subject($subject);
    });
    

    您会注意到上面示例中的第二个参数是 [] 而不是 null

    附带说明,'mail.from["address"]' 可能无法按您预期的方式运行。这将寻找一个名为 from["address"] 的键,包括 mail.php 配置文件中的双引号。

    【讨论】:

      猜你喜欢
      • 2020-01-17
      • 2023-03-28
      • 2016-06-13
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 2019-10-18
      • 2015-02-26
      • 2017-05-24
      相关资源
      最近更新 更多