Ad

Sending Mails With No Data On Laravel

- 1 answer

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.

Ad

Answer

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.

Ad
source: stackoverflow.com
Ad