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 git.master, git.master_jit
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 rfc.property-hooks
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)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
37 ms | 402 KiB | 8 Q