I have some strange problem here, socket connection to smtp.gmail.com fails when I try to execute script on site with Warning: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /var/www/test/test.php on line 2
php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
, but work fine if i run it in shell like php test.php
, telnet works fine too and openssl connection as well, but web script just fail. I looked a lot of similar issues and didn't found an answer for that, any suggestions?
I run nginx + php-fpm if, openssl enabled
UPD: here is my test script:
$fp = fsockopen("ssl://smtp.gmail.com", 465, $errno, $errstr, 10);
if (!$fp) {
echo "$errstr ($errno)<br />
";
} else {
echo "opened";
}