Connection could not be established with host mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known. #0]

后端 未结 8 1720
予麋鹿
予麋鹿 2020-12-19 02:07

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

相关标签:
8条回答
  • 2020-12-19 02:35

    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.

    0 讨论(0)
  • 2020-12-19 02:35

    Edit and following this file: config / mail.php

    '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'),
    

    Don't touch for these two lines

    'username' => env('MAIL_USERNAME'),
    
    'password' => env('MAIL_PASSWORD'),
    

    Edit and following this file: /.env

    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"
    

    Use below artisan command.

    Clear cache using artisan command

    php artisan config:clear

    Clear config

    php artisan cache:clear

    Restart your server

    sudo service httpd restart

    It will be works! Enjoy your coding

    0 讨论(0)
  • 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 .

    0 讨论(0)
  • 2020-12-19 02:40

    Use below code in .env file:

    MAIL_ENCRYPTION= TLS
    

    Try to clear cache , config cache , and restart apache2.

    It works.

    0 讨论(0)
  • 2020-12-19 02:43

    After modify your settings you need to run: php artisan config:cache

    Without those laravel will use old ones.

    0 讨论(0)
  • 2020-12-19 02:47

    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

    0 讨论(0)
提交回复
热议问题