Laravel: Use Email and Name in Mail::to

In laravel 5.6, answer to your question is: use associative array for every recpient with 'email' and 'name' keys, should work with $to, $cc, $bcc

$to = [
    [
        'email' => $email, 
        'name' => $name,
    ]
];
\Mail::to($to)->send(new \App\Mail\Hello);

You can use the Mail::send() function that inject a Message class in the callable. The Message class has a function to($email, $name) with the signature you're searching, i.e.:

Mail::send($view, $data, function($message) use ($email, $name) {
    $m->to($email,  $name);
    $m->from('[email protected]', 'Your Name'); 
    $m->subject('Hi there');
})

The $view could be a string (an actual view) or an array like these:

['text'=> 'body here']
['html'=> 'body here']
['raw'=> 'body here']

The $data argument will be passed to the $view.


You can use Mailable class in Laravel: https://laravel.com/docs/5.5/mail

php artisan make:mail YouMail

These classes are stored in the app/Mail directory.

In config/mail.php you can configue email settings:

'from' => ['address' => '[email protected]', 'name' => 'App Name'],