<?php $email = 'user@example.org'; function readSMTP($fsck) { $res = ''; do { $x = @fgets($fsck, 2048); $res .= $x; } while (strlen(trim($x))>0); return $res; } /* * eMail-validation via asking the appropriate mail server * code taken from http://www.zend.com/zend/spotlight/ev12apr.php * modified by Markus Birth <mbirth@webwriters.de> */ list( $em_user, $em_domain) = split('@', $email); if (getmxrr($em_domain, $em_mxhost)) { $em_connectaddress = $em_mxhost[0]; } else { $em_connectaddress = $em_domain; } $em_connect = @fsockopen($em_connectaddress, 25, $errno, $errstr, 5); if ($em_connect) { $host = $_SERVER['HTTP_HOST']; if (empty($host)) $host = $_SERVER['SERVER_NAME']; stream_set_timeout($em_connect, 2); if (ereg('^220', $em_out = @fgets($em_connect, 2048))) { fputs($em_connect, "HELO " . $host . "\r\n"); $em_out = trim(readSMTP($em_connect)); if (strpos($host, '.') !== FALSE) { $dom = explode('.', $host); $c = count($dom); $sender = 'validate@' . $dom[$c-2] . '.' . $dom[$c-1]; } else { $sender = 'validate@' . $host; } fputs($em_connect, "MAIL FROM: <$sender>\r\n"); $em_from = trim(readSMTP($em_connect)); fputs($em_connect, "RCPT TO: <$email>\r\n"); $em_to = trim(readSMTP($em_connect)); fputs($em_connect, "QUIT\r\n"); fclose($em_connect); $emp = @fopen('login_errors.txt', 'at'); @fwrite($emp, "Host: {$_SERVER['HTTP_HOST']} (" . date('Y-m-d H:i.s') . "\neMail from: $sender\neMail to check: $email\nMX: $em_connectaddress (" . implode(', ', $em_mxhost) . ")\nem_helo: $em_out\nem_from: $em_from\nem_to: $em_to\n<===>\n"); @fclose($emp); if (!ereg('^250', $em_to)) { return array('error' => true, 'error_msg' => 'Der zuständige eMail-Server kennt die eMail-Adresse nicht. Bitte überprüfe sie noch einmal.'); } } else { return array('error' => true, 'error_msg' => 'Der zuständige eMail-Server antwortet nicht. Prüfe Deine eMail-Adresse!'); } } else { return array('error' => true, 'error_msg' => 'Kann nicht zum eMail-Server zwecks Überprüfung der Adresse verbinden. Prüfe Deine eMail-Adresse oder probiere es später nochmal.' . " ($errno: $errstr)"); } return array('error' => false, 'error_msg' => ''); ?>