How to change From Name in Laravel Mail Notification

You can use

 Mail::send('emails.welcome', $data, function($message)
    {
        $message->from('[email protected]', 'Laravel');

        $message->to('[email protected]')->cc('[email protected]');
    });

Reference - https://laravel.com/docs/5.0/mail


In config/mail.php

set from property as:

'from' => ['address' => '[email protected]', 'name' => 'Firstname Lastname']

Here, address should be the one that you want to display in from email and name should be the one what you want to display in from name.

P.S. This will be a default email setting for each email you send.

If you need to use the Name as a variable through code, you can also call the function from() as follows (copying from Brad Ahrens answer below which I think is good to mention here):

return $this
    ->from($address = '[email protected]', $name = 'Sender name')
    ->subject('Here is my subject')
    ->view('emails.view');

A better way would be to add the variable names and values in the .env file.

Example:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

MAIL_FROM_NAME="My Name"
[email protected]

Notice the last two lines. Those will correlate with the from name and from email fields within the Email that is sent.