When I user mail function in laravel, show me this error
Connection could not be established with host smtp.gmail.com [A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
10060]
This is my .env
file config
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myacount@gmail.com
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
In your local PC(with xampp/wamp) try the following steps if you want to work with Gmail
https://www.google.com/settings/security/lesssecureapps give permission for lesser secured app
change your config like this
MAIL_DRIVER='sendmail' MAIL_HOST='smtp.gmail.com' Or '173.194.65.108' MAIL_PORT=587 MAIL_USERNAME='expense@blabla.com' MAIL_PASSWORD="secret" MAIL_ENCRYPTION="tls"
Artisan::call('view:clear'); Artisan::call('route:clear'); Artisan::call('config:clear'); Artisan::call('cache:clear'); Artisan::call('config:cache');
NB - your cmd will be like: php artisan view:clear .....etc. Its important to clear your cache you change in .env . Me personally also restart the xampp as I read somewhere .env files load when apache starts!
Now try to send the mail , it should work if your network administrator did not blocked it[unintentionally! In my cases he even do not know for which change it stopped to sending mail]
I use these steps with laravel 5.2 and it worked fine but recently something is changed by either google Or My network administrator so its not sending mail from xampp but working fine in shared hosting.
NB- I listed these because at least it worked on real hosting for which I spent much time to troubleshoot.
只需重新启动XAMPP(Apache和MySQL),然后再次运行PHP Artisan,一切就好了。
Make sure you install Guzzle to your project by adding the following line to your composer.json file:
"guzzlehttp/guzzle": "~5.3|~6.0"
reference Connection could not be established with host smtp.gmail.com Laravel
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.