I've got a script which does email verification by connecting to the domain's mx server. The script in a nutshell:


Code:
$connect = @fsockopen($connectaddress, 25) 
if($connect){ 
  if(ereg("^220, $out = fgets($connect, 1024))){ 
    fputs ($connect , "HELO $HTTP_HOST\r\n"); 
    $out = fgets ($connect, 1024); 
    fputs ($connect , "MAIL FROM: $fromemail\r\n"); 
    $from = fgets ($connect, 1024); 
    fputs ($connect , "RCPT TO: $toemail\r\n"); 
    $to = fgets ($connect, 1024); 
    fputs ($connect , "QUIT"); 
    fclose($connect); 
    if(!ereg("^250", $from) || !ereg("^250", $to)) 
      return "The email address does not exist"; 
  } 
}


So basically, I open a socket, sent a HELO, then send MAIL FROM and RCPT TO and capture the returns, which I check for code 250 (OK). If it does not return OK then the address is deemed invalid.

The problem is that I'm finding its rejecting valid email addresses. The RCPT TO call is returning 550 - Blocked on email addresses that I know are valid. If I perform the same procedure via telnet, I get 220 returning from the RCPT call.

Any ideas ?