Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: How to access config/Mail variables

Tags:

php

laravel

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.

like image 826
maudev Avatar asked Aug 02 '17 06:08

maudev


2 Answers

I think you can directly access MAIL_NAME from .env

env('MAIL_NAME');

OR

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

Hope this work for you !!!

like image 68
AddWeb Solution Pvt Ltd Avatar answered Sep 30 '22 12:09

AddWeb Solution Pvt Ltd


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')

like image 20
yoeunes Avatar answered Sep 30 '22 14:09

yoeunes