Abhilash KM
Abhilash KM

Reputation: 109

Laravel Email sending

I am using laravel-sendgrid-driver (https://github.com/s-ichikawa/laravel-sendgrid-driver?_pjax=%23js-repo-pjax-container ).

It sends email for normal Text. I need to send some 4-5 lines subject. But unable to send email. Shows Errors like "Argument 2 passed to Illuminate\Mail\Mailer::send() must be of the type array, string given,"

$emailTemplate = str_replace($searchArray, $tmpVal, $email);

 Mail::send( [], $emailTemplate, function ($message){
                $message->to($userDetail[0]->email)
                        ->from('[email protected]', 'test-Technologies')
                        ->subject('Forgot Password');
            });

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

Upvotes: 1

Views: 144

Answers (1)

Dilip Hirapara
Dilip Hirapara

Reputation: 15316

The send method accepts three arguments.

First, the name of a view that contains the e-mail message.

Secondly, an array of data you wish to pass to the view.

Lastly, a Closure callback which receives a message instance, allowing you to customize the recipients, subject, and other aspects of the mail message:

Mail::send('viewfilename', ['name' => 'Abhilash KM'], function ($m) use ($userDetail) {
            $m->from('[email protected]', 'test-Technologies');
            $m->to($userDetail[0]->email)->subject('Forgot Password');
        });

Upvotes: 1

Related Questions