Laravel keeps using hello#example.com with changed conf - laravel

In mail.php I have changed from fields but I still get mails with demo values. There is no reference to hello#example.com in project, yet I still get this in mail.
'from' => [
'address' => 'do-not-reply#mysite.net',
'name' => 'MySite.net',
],
Does anyone have an idea what might be wrong?

Clear the config cache by running the following Artisan command:
php artisan config:clear

If you are using supervisor, ensure you set the right user in the conf file, otherwise you will see the emails are being sent as hello#example.com.
In my case the user is www-data - I set it up as root before and was getting this issue.

Related

I cannot disable Laravel debug logging?

I kept running the debug logging level for some time for my application also on prod, after now 2 weeks, I wanted to disable it. So I went ahead and opend the .env variable and set APP_DEBUG=false
I did a php artisan down, php artisan cache:clear, then php artisan config:clear, php artisan config:cache and brought it back up. To be fully safe here.
I went back in the log file after a minute or so and still saw production.DEBUG appearing.
I then retried all the steps, checked the config/app.php file and made sure that nothing is wrong in there. But everything looks fine.
Then I went to my local environment and tried the same but to my surprise the application still keeps logging debug messages also on local!
I cannot get it disabled!
What I tried:
php artisan config:clear / :cache / cache:clear optimize:clear / down / up ...
I checked the app.php file, the config/logging.php but all looks fine
APP_ENV=production, APP_DEBUG=false
Then to my surprise I tried something:
I changed LOG_LEVEL=info in the .env file -> no change
I opened the config/logging.php and went to the daily section (because LOG_CHANNEL=daily) and set the 'level' entry to 'info' => IT WORKS! both on PROD and LOCAL
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'info',
'days' => 21,
],
Can someone explain to me, why this is happening?
I was under the impression that the APP_DEBUG and the LOG_LEVEL should be the key indicators for Laravel but somehow they aren't?!
Might that be related to the LARAVEL DEBUGBAR? I have it installed.
Laravel version 7, php 7.4 (local Homestead, prod apache)

SOLUTION for: Expected response code 250 but got code "530", with message "530 5.71 Authentication required

This first code was what solved everything. Use this code exactly inside your config/mail.php file. With your own full Gmail address and Google app password.
Where I got the solution
'username' => env('MAIL_USERNAME','full-gmail-address-here'),
'password' => env('MAIL_PASSWORD','Google-app-password-generated-when-setting-up-2-factor-auth'),
You might have written this 2nd code but here it is ... Goes inside your env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587 (or use 465 for ssl on the sixth line below)
MAIL_USERNAME=Your-full-Gmail-address-here
MAIL_PASSWORD=Your-Google-App-Password-here
MAIL_ENCRYPTION=tls (or ssl)
MAIL_AUTH=YES (<= I made this up, if you're a pro you can check if it's necessary)
MAIL_FROM_ADDRESS=Email-address-of-sender
MAIL_FROM_NAME=Name-of-sender
Thirdly, don't forget to include this inside the config/mail.php file
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
Please pass it on to whoever may need it. Thanks
When change in .env you just clear cache & config
php artisan cache:clear
php artisan config:clear
Then test your .env data
php artisan tinker
config('mail')
check your data is correct or not.Your process is correct here.

Emails keep being sent from Example <hello#example.com>

Already read a lot and even did php artisan config:clear
Checked thourghout all files and hello#example.com is nowhere.
It works from local w/o problems.
Also, have another app in plain PHP that uses PHPMailer and this issue does not happen so I don't think it would be something related to the server.
Any help appreciated hence this script is only waiting this issue to be solved so it can be live.
UPDATE: The issue was with the mail server. We changed the mail server
to a different machine but didn't configure completely the DNS.
Thanks to both for answering.
Email address is configured in config/mail.php file
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
but how you can see it is using environment vars configured in .env in root directory
MAIL_FROM_ADDRESS=info#blabla.com.ar
MAIL_FROM_NAME="San Marino Pastas"
Remeber if you are using artisan serve or queue listining restart the services to take the new config.
Please try this and let me know how it works :)
1)First of all you have to set the environment variable in .env file
MAIL_DRIVER=mail
MAIL_HOST=mail.abc.com
MAIL_PORT=465
MAIL_USERNAME=info#abc.com
MAIL_PASSWORD=abc123
MAIL_ENCRYPTION=null
2) Then import this in your controller,
use Illuminate\Support\Facades\Mail;
3) Then add this function in your controller,
public function basic_email() {
$data = array('name'=>"Virat Gandhi");
Mail::send(['text'=>'mail'], $data, function($message) {
$message->from('info#abc.com');
$message->subject('Testing');
$message->to('abc#gmail.com');
echo "Basic Email Sent. Check your inbox.";
});
4) I hope this helped you.

Laravel can't change config value

I found the problem, i'll try to use a homestead or docker.
if i restart php artisan serve the changed values are applied.
Same my post: Laravel can't change config value
I make route
Route::get('/config', function () {
return dd(config('app'));
});
And cant change my config/app.php, for example i want to change
'url' => env('APP_URL', 'test'),
'client_url' => env('APP_CLIENT_URL', 'test'),
I set
APP_CLIENT_URL=str1
APP_URL=str2
and there is something inexplicable:
My "url" => "http://127.0.0.1:8000" !!! not default 'test' or from .env, I did not set such a value.
My client_url contains the old value, after I cached the config.
This is not production, i accidentally run config:cache, but after i remove all cache from bootsrap/cache, storage/framework/cache and running cache:clear, config:clear.
After running config:cache values from the .env were put in config, but I do not want to constantly change cache in development and it is not recommended in the documentation.
How can I easily change .env in in developing?

Laravel - 'Auth guard [admin] is not defined.'

This is a fresh copy of Laravel 5.6.
using spatie laravel permissions.
I have maybe altered something while dealing with permissions that could have altered the guard. I have no idea what since I can't see any git changes, maybe via the DB?
At first I tried to tinker and give a specific user admin privileges with:
$role = Spatie\Permission\Models\Role::where('name', 'admin')->get()->first();
When that returned undefined, I checked Auth::guard('admin'), that returns undefined, so I understand that the issue has nothing to do with Spatie package.
After looking in a few questions/answers here on stackoverflow, one of them being config:clear and config:cache, which didn't work and still getting undefined for Auth guard admin.
Any other options I could take to get Auth admin?
thanks
In case you edited your config/auth.php, e.g. to add another guard and your config is cached, your guards may not be reloaded. If you experience this problem, clearing the config will fix it.
https://github.com/laravel/laravel/blob/v5.2.0/config/auth.php
php artisan config:clear OR php artisan config:cache
I'm using Laravel 5.4.
Add admin or administrator to the auth guards. After this php artisan config:clear can be run to remove the previous cached configurations. It should match your roles->name in the database.
\config\auth.php (file)
'guards' => [
...
'administrator' => [
'driver' => 'session',
'provider' => 'users',
],
],
An old question, but stil valid from Laravel 5 to 7

Resources