Carlos Diaz
Carlos Diaz

Reputation: 381

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:

 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.

Upvotes: 1

Views: 521

Answers (1)

Ben Swinburne
Ben Swinburne

Reputation: 26477

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.

On a side note, 'mail.from["address"]' probably won't function as you expect. That'll look for a key called from["address"] including the double quotes inside the mail.php config file.

Upvotes: 1

Related Questions