Reputation: 5161
I'm using laravel 7.x with mailgun running on my local environment and everything seems to be running fine. I want to be able to set the from "name" when sending individual emails.
In Laravel 7.x documentation on "Configuring The Sender" they explain how to send an email and specify a "from address", but do not show how to set a name.
return $this->from('[email protected]')
->view('emails.orders.shipped');
They also specify how to set a global from address with the name set
'from' => ['address' => '[email protected]', 'name' => 'App Name'],
I want to be able to send an email where I can set multiple names depending on which part of the application I'm sending from. (e.g. password reset would be different from a usage notification)
The example below returns Swift_RfcComplianceException: Address in mailbox given [Test User <[email protected]>] does not comply with RFC 2822, 3.6.2
return $this->from('Test User <[email protected]>')
->view('emails.orders.shipped');
I also tried using the array syntax from the global method, but this didn't seem to have any impact on the name itself.
return $this->from([
'address' => '[email protected]',
'name' => 'Test User'
])
->view('emails.orders.shipped');
Is it possible to set the name using this method?
Upvotes: 0
Views: 96
Reputation: 1056
You should use this syntax:
$this->from('[email protected]','Example')->view('emails.orders.shipped');
I could not find the proper documentation for this, but similar syntax was used in laravel emails.
Upvotes: 1