You can use sockets and connect to their mail server (bit after the @) and "pretend" to send an email to them, but cancel the request before you actually send anything - doesn't always work though, as some servers will report back the all users are correct
This is the code I use - a bit long though - if anyone can find a better way, please email me <? // ---------------------------------------------------------------------------- if (!class_exists("mail_exchange_class")) { class mail_exchange_class { // ------------------------------------------------------------------------ function get_mx_reply($f) { $body = ""; do { $line = fgets($f, 1024); $body .= "$line\n"; $ch = substr($line, 3, 1); } while ($ch == "-"); return $body; } // ------------------------------------------------------------------------ function send_mx_msg($f, $str) { fputs($f, $str); return mail_exchange_class::get_mx_reply($f); } // ------------------------------------------------------------------------ function check_email($email) { list($user, $host) = explode("@", $email); // --- check if there's a mail server // ------------------------------------- if (!getmxrr($host, $mx_arr, $wt_arr)) { return false; } // --- check if user exists at mail server // ------------------------------------------ // try connecting to one of the mail servers $i = 0; $num_mx = count($mx_arr); do { $mx_server = $mx_arr[0]; $f = fsockopen($mx_server, 25); $i++; } while (!$f && $i < $num_mx); if (!$f) { return false; } // "talk" with mail server to determine user validity $flag = true; // default to: user exists $rep = mail_exchange_class::get_mx_reply($f); // welcome message $rep = mail_exchange_class::send_mx_msg($f, "helo anonymous\n"); // introduce ourselves $rep = mail_exchange_class::send_mx_msg($f, "mail from:<$email>\n"); // say we want to send a msg $rep = mail_exchange_class::send_mx_msg($f, "rcpt to:<$email>\n"); // say who it's to if (substr($rep, 0, 3) != "250") // check if user exists { $flag = false; // ... now we know they don't exist } $rep = mail_exchange_class::send_mx_msg($f, "rset\n"); // reset all the buffers $rep = mail_exchange_class::send_mx_msg($f, "quit\n"); // log off from server fclose($f); // return status return $flag; } } } ?> then to use: $email = "[EMAIL PROTECTED]"; if (mail_exchange_class::check_email($email)) ; // user probably exists else ; // user doesn't exist, or can't connect to server I think that's all you need of this code - there's lots more, there's an email class and an attachment class that goes with it, but it's need to check the address HTH Martin -----Original Message----- From: Simon Willison [mailto:[EMAIL PROTECTED]] Sent: Monday, February 25, 2002 9:27 AM To: Steven Walker Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Email Verification Steven Walker wrote: > Does anybody know any good ways (or available code) for verifying > email addresses? > > Checking syntax is not enough.. I'd like to actually be able to test > whether the email address exists. The only way to be sure is to send them an e-mail with a link or validation code that they must use to prove the address exists - or if it's for an account just tell them that the (random) password for their account will be e-mailed to the address they provide. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php