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

Asked
Active3 hr before
Viewed126 times

5 Answers

90%

Connection could not be established with host smtp.gmail.com [php_network_getaddresses: getaddrinfo failed: No such host is known., Stack Overflow Public questions & answers ,Stack Overflow en español, Meta Stack Overflow

Clear cache using artisan command

php artisan cache: clear

Clear config

php artisan config: clear

Restart your server

sudo service apache2 restart
load more v
88%

How could not be established with host mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known. #0] Error Occurs?,How To Solve could not be established with host mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known. #0] Error ?, To Solve could not be established with host mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known. #0] Error After modify your settings you need to run: php artisan config:cacheWithout those laravel will use old ones. , To Solve could not be established with host mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known. #0] Error After modify your settings you need to run: php artisan config:cacheWithout those laravel will use old ones.

php artisan cache: clear
load more v
72%

In Laravel project directory, edit config / mail.php and add the following:
   'stream' => [
      'ssl' => [
         'allow_self_signed' => true,
         'verify_peer' => false,
         'verify_peer_name' => false,
      ],
   ]

It worked
for me.

Fyi, my SMTP settings are:
   MAIL_DRIVER = smtp
MAIL_HOST = smtp.gmail.com
MAIL_PORT = 465
MAIL_USERNAME = [Full Gmail Address]
MAIL_PASSWORD = [Google App Password obtained after two step verification on Google Account Page]
MAIL_ENCRYPTION = ssl
load more v
65%

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. ,Most likely the encryption type and port., Collections → ,I am sure these are incorrect:

    if (isset($this - > params['stream_context_options'])) {
       $options = array_merge($options, $this - > params['stream_context_options']);
    }
    $streamContext = stream_context_create($options);
    $this - > stream = @stream_socket_client($host.
       ':'.$this - > params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
    if (false === $this - > stream) {
       throw new Swift_TransportException(
          'Connection could not be established with host '.$this - > params['host'].
          ' ['.$errstr.
          ' #'.$errno.
          ']'
       );
    }
    if (!empty($this - > params['blocking'])) {
       stream_set_blocking($this - > stream, 1);
    } else {
       stream_set_blocking($this - > stream, 0);
    }
    stream_set_timeout($this - > stream, $timeout);
    $this - > in = & $this - > stream;
    $this - > out = & $this - > stream;
    }
load more v
75%

Swift_TransportException Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known.,Greetings master devs. I have this mail class that is to send an email after user is manually verified in the admin backend. I copied credentials from mailtrap.io into my env file to test the mail but received this feedback when email class is invoked.

mailtrap crredentials

MAIL_MAILER = smtp
MAIL_HOST = smtp.mailtrap.io
MAIL_PORT = 2525
MAIL_USERNAME = secrete
MAIL_PASSWORD = secrete
MAIL_ENCRYPTION = tls
MAIL_FROM_NAME = "${APP_NAME}"

Other "undefined-undefined" queries related to "Connection could not be established with host mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known. #0]"