Renee,

I'm pretty rusty at programming, but I'm not sure if what you are trying to do is reasonable.  (check an email address to see if it is valid)

If you try this with my email server, it is using greylisting, so your first attempt would be greeted with "temporary failure - come back later".  You would need to make a delivery attempt an hour later for it to actually be accepted.  I'm pretty sure the main mail.msu.edu still uses greylisting, and it is a popular strategy with all email servers.

Looking at your code, maybe you are just trying to tell if the hostname has an SMTP server there, not really checking the actual email address?  That might be reasonable to check.

-John

PS - you might try a fsocketopen("msu.edu",25 ....) to make sure a simple case works first (on your server).




On Apr 29, 2009, at 2:44 PM, Renee Starkey wrote:

Hello
 
I am trying to use fsockopen() php function to check a valid email address.  Here is a code snippet:
 
function checkEmail($email) {
 if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) {
  return FALSE;
 }
 list($Username, $Domain) = split("@",$email);
 if(getmxrr($Domain, $MXHost)) {
  return TRUE;
 } else {
  if(fsockopen($Domain,25,$errno,$errstr,30)) {
   return TRUE;
  } else {
   return FALSE;
  }
 }
}
Here is the error from the browser:
 
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in file name line...
 
Here is the failing on the if(fsockopen($Domain,25,$errno,$errstr,30)) line.  Does anyone out there have any experience with this error??  I am using a LAMP server.
 
Thank you,
 
Renee Starkey @}-----}-----
Information Technologist I
115 Old Horticulture
Language Learning Center, Michigan State University
Phone: 517-355-7587
 
 
Renee Starkey ;-)
"Strive to be the best you can be at any given moment in life" RmS