3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // эта функция отправляет команду в сокет, и возвращает ответ от сервера function sWrite( $socket, $data, $echo = true ){ // отображаем отправляемую команду, если это требуется if( $echo ) echo $data; // отправляем команду в сокет fputs( $socket, $data ); // получаем первый байт ответа от сервера $answer = fread( $socket, 1 ); // узнаем информацию о состоянии потока $remains = socket_get_status( $socket ); // и получаем оставшиеся байты ответа от сервера if( $remains --> 0 ) $answer .= fread( $socket, $remains['unread_bytes'] ); // функция возвращает ответ от сервера на переданную команду return $answer; } // адрес электропочты, который надо проверить $email = "twixed@mail.ru"; // получаем данные об MX-записи домена, указанного в email $mx = dns_get_record( end( explode( "@", $email ) ), DNS_MX ); $mx = $mx[0]['target']; // открываем сокет и создаем поток $socket = fsockopen( $mx, 25, $errno, $errstr, 10 ); if( !$socket ){ echo "$errstr ($errno)\n"; }else{ // отправляем пустую строку, чтобы получить приветствие сервера echo sWrite( $socket, "" ); // представляемся сами echo sWrite( $socket, "EHLO example.com\r\n" ); echo sWrite( $socket, "MAIL FROM: dummy@example.com\r\n" ); // запрашиваем разрешение на отправку письма адресату $response = sWrite( $socket, "RCPT TO: $email\r\n" ); echo $response; // закрываем соединение echo sWrite( $socket, "QUIT\r\n" ); fclose( $socket ); // ниже идет простейшая обработка полученного ответа echo "\nCheck report:\n"; if( substr_count( $response, "550" ) > 0 ) echo "Required email address does not exist.\n\n"; else if( substr_count( $response, "250" ) > 0 ) if( substr_count( $response, "OK" ) > 0 ) echo " Required email address exists.\n\n"; else echo " Email address accepted but it looks like the server is working as a relay host.\n\n"; else echo " Required email address existence was not recovered. Last response:\n ---\n$response ---\n\n"; }
Output for 7.0.0 - 7.0.3, 7.0.5 - 7.1.0
Notice: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): A temporary server error occurred. in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
Output for 7.0.4
Notice: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): A temporary server error occurred. in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: System error (0)
Output for 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 5.6.28
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): A temporary server error occurred. in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
Output for 5.5.33, 5.6.18 - 5.6.19
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): A temporary server error occurred. in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: System error (0)
Output for 5.3.2 - 5.3.28, 5.4.0 - 5.4.27, 5.4.42 - 5.4.45
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Notice: Undefined offset: 0 in /in/Ll4ok on line 24 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: System error (0)
Output for 5.3.29, 5.4.28 - 5.4.41
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Notice: Undefined offset: 0 in /in/Ll4ok on line 24 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
Output for 5.3.1
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: System error (0)
Output for 5.2.6 - 5.3.0
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): res_nsend() failed in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (php_network_getaddresses: getaddrinfo failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo failed: System error (0)
Output for 5.1.0 - 5.2.0, 5.2.2 - 5.2.5
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): res_nsend() failed in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (Unknown error) in /in/Ll4ok on line 26 (0)
Output for 5.2.1
Strict Standards: Only variables should be passed by reference in /in/Ll4ok on line 23 Warning: dns_get_record(): res_nsend() failed in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (Unknown error) in /in/Ll4ok on line 26 (1952802655)
Output for 5.0.5
Fatal error: Only variables can be passed by reference in /in/Ll4ok on line 23
Process exited with code 255.
Output for 5.0.3 - 5.0.4
Warning: dns_get_record(): res_nsend() failed in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (Unknown error) in /in/Ll4ok on line 26 (0)
Output for 5.0.0 - 5.0.2
Warning: dns_get_record(): res_nsend() failed in /in/Ll4ok on line 23 Warning: fsockopen(): php_network_getaddresses: gethostbyname failed in /in/Ll4ok on line 26 Warning: fsockopen(): unable to connect to :25 (Unknown error) in /in/Ll4ok on line 26 (0)
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: dns_get_record() in /in/Ll4ok on line 23
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: dns_get_record() in /in/Ll4ok on line 23
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: dns_get_record() in /in/Ll4ok on line 23