Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change From Name in Laravel Mail Notification

This is the problem:

This is the problem

I need help for this one. Thanks

like image 264
Masterpiece Mas Icang Avatar asked Feb 01 '17 05:02

Masterpiece Mas Icang


People also ask

How do I get email notifications in Laravel?

Send Email Notifications in Laravel php use App\Notifications\Newvisit; Route::get('/', function () { $user = App\User::first(); $user->notify(new Newvisit("A new user has visited on your application.")); return view('welcome'); });

What is the difference between mail and notification in Laravel?

From what I understand, Mailables are used to send only emails whereas Notifications can be used to send emails and sms.


1 Answers

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.

EDIT: 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'); 
like image 100
Dev Avatar answered Sep 29 '22 22:09

Dev