简体   繁体   English

在Laravel上发送无数据的邮件

[英]Sending mails with no data on Laravel

I got this: 我懂了:

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

And laravel is telling me: laravel告诉我:

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

I don't need send data, my email template is not sending data except an attached which has all data for the customer. 我不需要发送数据,我的电子邮件模板没有发送数据,除了附件中包含了所有客户数据的附件。

Just pass an empty array 只需传递一个空数组

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

You'll notice the [] instead of null as the second parameter in the example above. 在上面的示例中,您会注意到[]而不是null作为第二个参数。

On a side note, 'mail.from["address"]' probably won't function as you expect. 附带说明一下, 'mail.from["address"]'可能无法按预期运行。 That'll look for a key called from["address"] including the double quotes inside the mail.php config file. 这将查找名为from["address"]的键from["address"]其中包括mail.php配置文件中的双引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM