I
I
Issue2021-07-28 16:38:57
PHP
Issue, 2021-07-28 16:38:57

Why is there an Undefined offset: 1 error in laravel when sending an email?

Error description:

ErrorException
Undefined offset: 1

In the file vendor/laravel/framework/src/Illuminate/Mail/Mailer.php
On line 298
if (is_array($view) && isset($view[0])) {
            return [$view[0], $view[1], null];
}


All this happens when I call the send() function in my file:
function send($text, $email, $username){
                Mail::send(['text'], ['name', 'Уведомление'], function ($message){
                    $message->to($email, $username)->subject('Напоминание о событии');
                    $message->from('[email protected]', 'From');
                }); // <<< SendController.php:52
            }


What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2021-07-28
@Fragster

6101622a617e8322210925.png

J
jazzus, 2021-07-28
@jazzus

In Laravel, the email is sent like this Or through notification with the installation of via mail
Mail::to($user)->send(new MyMailClass($message));
$user->notify(new MyNotifyClass($message));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question