7

I need to get address and name variables on my Mail.php config:

'from' => ['address' => env('MAIL_USERNAME'), 'name' => env('MAIL_NAME')],

I tried this:

Config::get('mail.from.*.name');
Config::get('mail.from["name"]');  

But it doesn't work, what do I do to get them? Thanks.

1
  • 3
    Tried Config::get('mail.from.name'); ? Commented Aug 2, 2017 at 6:33

3 Answers 3

8

I think you can directly access MAIL_NAME from .env

env('MAIL_NAME');

OR

Config::get('mail.from.name');

Hope this work for you !!!

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah that is it !
overall it's better to use the config method, in a production environment with the "config:cache" command advised in the doc the .env file isn't accessible
5

this is the shortest method i know using helper methods :

config('mail.from.name')

or you can access it using your .env file with env('MAIL_NAME')

Comments

0

it is preferable put your mail name in your configuration file and access it with env function like this :

env('MAIL_NAME')

1 Comment

Better to use the config() helper. Laravel will use what config() returns, so changing the config to 'from' => ['address' => '[email protected]', 'name' => 'Something Hard Coded'], would cause this to output the wrong information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.