I am getting below error:
Connection could not be established with host smtp.gmail.com [php_network_getaddresses: getaddrinfo failed: No such host is kno
I just had this same problem.
It looks like the server is not able to ping the destination address.
I did a quick restart of my dev server and everything is back to normal.
Hope that helps.
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'your mail host'),
'port' => env('MAIL_PORT', '465'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'Your email address'),
'name' => env('MAIL_FROM_NAME', 'Your email Name'),
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
MAIL_DRIVER=smtp
MAIL_HOST=your mail host
MAIL_PORT=465
MAIL_USERNAME=Your smtp email address
MAIL_PASSWORD=Your smtp password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=Your email address
MAIL_FROM_NAME="Your email Name"
php artisan config:clear
php artisan cache:clear
sudo service httpd restart
It will be works! Enjoy your coding
Edit .env
file :
MAIL_HOST=smtp.gmail.com
Edit Config/mail.php
file :
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
.env
and mail.php
should both correspond to each other .
Use below code in .env
file:
MAIL_ENCRYPTION= TLS
Try to clear cache
, config cache
, and restart apache2
.
It works.
After modify your settings you need to run: php artisan config:cache
Without those laravel will use old ones.
The problem is actually a simple typo. In your .env file, change this:
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
to this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
I prepended the smtp.
to the host