3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.3.0 - 8.3.6
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: Trying to access array offset on false in /in/Ll4ok on line 24 Warning: Trying to access array offset on null in /in/Ll4ok on line 24 Deprecated: fsockopen(): Passing null to parameter #1 ($hostname) of type string is deprecated in /in/Ll4ok on line 26 Warning: fsockopen(): php_network_getaddresses: getaddrinfo for failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): Unable to connect to :25 (php_network_getaddresses: getaddrinfo for failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo for failed: System error (0)
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
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: Trying to access array offset on value of type bool in /in/Ll4ok on line 24 Warning: Trying to access array offset on value of type null in /in/Ll4ok on line 24 Deprecated: fsockopen(): Passing null to parameter #1 ($hostname) of type string is deprecated in /in/Ll4ok on line 26 Warning: fsockopen(): php_network_getaddresses: getaddrinfo for failed: System error in /in/Ll4ok on line 26 Warning: fsockopen(): Unable to connect to :25 (php_network_getaddresses: getaddrinfo for failed: System error) in /in/Ll4ok on line 26 php_network_getaddresses: getaddrinfo for failed: System error (0)
Output for 8.0.13 - 8.0.30
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: Trying to access array offset on value of type bool in /in/Ll4ok on line 24 Warning: Trying to access array offset on value of type null 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 8.0.0 - 8.0.12
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: Trying to access array offset on value of type bool in /in/Ll4ok on line 24 Warning: Trying to access array offset on value of type null 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 7.4.0, 7.4.26 - 7.4.33
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 Notice: Trying to access array offset on value of type bool in /in/Ll4ok on line 24 Notice: Trying to access array offset on value of type null 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 7.4.3 - 7.4.25
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 Notice: Trying to access array offset on value of type bool in /in/Ll4ok on line 24 Notice: Trying to access array offset on value of type null 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 7.3.32 - 7.3.33
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 7.0.0 - 7.0.3, 7.0.5 - 7.0.14, 7.1.0, 7.2.29 - 7.2.33, 7.3.16 - 7.3.31
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, 7.0.20, 7.1.5 - 7.1.20, 7.2.6, 7.3.12
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.5.35, 5.6.7 - 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.2.17, 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.1.6, 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.3.11, 4.4.0 - 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

preferences:
242.27 ms | 401 KiB | 313 Q