Can't change MAIL_DRIVER to mailgun in Laravel 5.4 - laravel

I changed MAIL_DRIVER in .env file of production server like that:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAILGUN_DOMAIN=mg.xx.com
MAILGUN_SECRET=key-xx
MAIL_ENCRYPTION=null
I run these commands also:
php artisan config:clear
php artisan config:cache
However, they did not change MAIL_DRIVER. Server continues to send mail via old MAIL_DRIVER. I got from controller env("MAIL_DRIVER"), and it gets nothing (NULL).
How can I solve this problem.

You will need to restart your server and/or just re run php artisan serve on local dev.

Related

APP_URL not refreshing after a change

I'm building a Laravel 9 app using Docker.
I'm just starting, so I merely updated the APP_URL variable in the .env (from "http://localhost" to "http://mydomain.local").
After this, I ran the following commands:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump-autoload
and I restarted the Docker container of the app.
Yet, when I access http://mydomain.local in my browser, the app doesn't load. It still loads properly when I user http://localhost as originally configured.
What am I missing?
This is because you probably didnt edit the vhost..
Just changing the APP_URL in the .env file doesnt change how the browser resolves a domain name.
See this thread to learn how to edit a vhost file: WAMP Server virtual hosts configuration

Swift_TransportException: Expected response code 250 but got code "", with message "" in AbstractSmtpTransport.php:383

I have a laravel application that has been sending emails for Years now. Recently, emails have been failing to send. When I check the failed_jobs table, below is the error message:
Swift_TransportException: Expected response code 250 but got code "", with message "" in
/apps/www/ccc.xxxx.com/public_html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383
Below are things I have attempted:
composer dump-autoload
php artisan config:cache
php artisan config:clear
php artisan queue:restart
restarted supervisor
Ensure username and password is correct in .env file
I have connected to the mail box successfully and able to send email to anyone
Below is the .env config
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=g.blah#balh.com
MAIL_PASSWORD=Va##2016
MAIL_ENCRYPTION=TLS
What can be the issue and how to fix this ?
Laravel Swiftmailer abandoned but it's still working fine with PHP 7 versions, maybe your PHP has been upgraded by someone or server administrator. Please check your PHP version and look at this file in your Swiftmailer vendor and change it if necessary.
Replace 127.0.0.1 to gethostname() in lib/dependency_maps/transport_deps.php

Laravel Password reset link is pointing to old APP_URL

I have a Laravel 8 project which is using Laravel/UI for auth.
I changed the APP_URL in the .env file from the test domain extension to IP Address. But the password reset email is showing a link with the previous APP_URL as the base URL.
The following are steps that I have tried to solve this:
Change APP_URL in .env file
Change URL in config/app.php to the IP address instead of env variable.
Ran php artisan config:clear
Ran php artisan cache:clear
Ran php artisan optimize:clear
How can I solve this?
Try running these commands:
php artisan config:cache
php artisan queue:restart
The issue was with url from where I was submitting the form. Laravel/UI reset password uses route() method to get the url for the password reset. Hence why the change in APP_URL and url variable didn't affect the link. A detailed explanation is available here

php artisan serve does not allow change .env file

I found the problem
if i restart php artisan serve the changed values are applied. this is
the norm? how can i solve this
I created a router where I output config information
I'm trying to change value from .env file, for example APP_NAME, from APP_NAME="Nuxt + Laravel" to APP_NAME="test" but the change is not displayed on the page!(of course I reloaded the page šŸ˜Š)
I was trying to look through php artisan tinker
It works!
But my config remains the same. I can not solve this problem for a week now.
I cleared the cache!!! I tried php artisan cache:clear, php artisan config:clear (i tried all command for cache)
CACHE_DRIVER=file
I deleted files bootsprap/cache/*, storage/framework/cache/*.
I tried everything!!!
I have this project on the github: https://github.com/iliyaZelenko/laravel-nuxt.
Please help me, I want my project to be used by other people.

Why my email sender does not update when I change the settings in env laravel on staging server?

I use laravel 5.3 and I change env on the staging server on the forge (https://forge.laravel.com)
I change like this :
#MAIL_HOST=smtp.gmail.com
#MAIL_PORT=587
#MAIL_USERNAME=mygmail#gmail.com
#MAIL_PASSWORD=secret
#MAIL_ENCRYPTION=tls
MAIL_HOST=mail.myshop.id
MAIL_PORT=587
MAIL_USERNAME=contact#myshop.id
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
If I try send mail in my system, the email sender is mygmail#gmail.com
Should the email sender contact#myshop.id
How can I solve this problem?
I use laravel 5.7 running with supervisor to handle the queues. Following steps helped me out:
php artisan config:cache
This command refreshes the config file in the cache. you can check it in bootstrap/cache/config.php and look for the 'mail' array.
php artisan queue:restart
Tell the queue to use the new configs and restart the supervisor.
If the above commands didn't solve the problem, these commands might help:
php artisan cache:clear
sudo supervisorctl restart all
sudo nginx -s reload
Also, you can set your from address. Just take a look at config/mail.php file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=xxxxxxxxx
MAIL_PASSWORD=xxxxxxxxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply#youremail.com
MAIL_FROM_NAME=yourname
On Laravel 5.1 php artisan config:clear did not work. Instead, I needed to run
php artisan config:cache
Iā€™m hesitating between two possible issues..
First possibility: That might be because of the use of a cache by your artisan server if you are running your app with it.
So try to stop your artisan server and restart it
Second one: the email is set somewhere else. So check your config files (in config/ directory).
Hope this will help
I know this is an old question, but I was in the same situation and found something that worked for me
php artisan config:clear
Maybe can help someone else landing here.
php artisan config:clear;
to call this from a route (for shared hosting without SSH for example)
Artisan::call('config:cache');
MAIL CONFIGURATION on your ENV doesn't mean that will be your sender email to be display on the recipient that will just be the credentials to be used in order the email service work, if you want you may configure it using the mail.php configuration file in config folder or directly to the Mail function of laravel.
$mail->from(YOUR_EMAIL_ADDRESS,YOUR_DISPLAY_NAME);

Resources