I got stack on this error I trying to configure SMTP mail on laravel
here is my configuration on .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=fff3c01db52ee0
MAIL_PASSWORD=feaeda91dc9ab6
MAIL_ENCRYPTION=TLS
I have try to authenticate the SMTP on env but I keep get the same error so for now am stack on that error
your mail.php on config you declare host as smtp.mailgun.org and port is 587 while on env is different. you need to change your mail.php to
'host' => env('MAIL_HOST', 'mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
if you desire to use mailtrap.Then run
php artisan config:cache
I believe this has been answered in some sections already, just test with gmail for your "MAIL_HOST" instead and don't forget to clear cache. Setup like below:
Firstly, you need to setup 2 step verification here google security. An App Password link will appear and you can get your App Password to insert into below "MAIL_PASSWORD". More info on getting App Password here
MAIL_DRIVER=smtp
MAIL_FROM_ADDRESS=noreply@domain.com
MAIL_FROM_NAME=DomainName
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=YOUR_GMAIL@gmail.com
MAIL_PASSWORD=YOUR_GMAIL_CREATED_APP_PASSWORD
MAIL_ENCRYPTION=tls
Clear cache with:
php artisan config:cache
That is basically authentication error due to misconfiguration of email settings.
Go to .env
file
change
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
to
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=ENTER_YOUR_EMAIL_ADDRESS(GMAIL)
MAIL_PASSWORD=ENTER_YOUR_GMAIL_PASSWORD
MAIL_ENCRYPTION=ssl
The MAIL_USERNAME and PASSWORD should be replaced with your Gmail Email address and Password respectively. Login to your Google Account, Go to security settings and enable Allow Less Secure App switch button.
After that go to your project root directory and run the following command:
php artisan clear:cache && php artisan clear:config && php artisan config:cache
. Please refer to
this guide for assistance and clarification (Note: For MAIL_HOST use smtp.gmail.com)
I see you have all the settings right. You just need to end the local web server and start it again with
php artisan serve
Everytime you change your .env
file, you need tor restart the server for the new options to take effect.
Or clear and cache your configuration with
php artisan config:cache
Yep, and if you have tried all the above solutions (what's more likely to happen) and none work for you, it may happen that Guzzle is not installed.
Laravel ships mailing tools, by which is required the Guzzle framework, but it won't be installed, and AS OF the documentation, will have to install it manually:
https://laravel.com/docs/master/mail#driver-prerequisites
composer require guzzlehttp/guzzle