Jump to content

Archived

This topic is now archived and is closed to further replies.

grenouille

Undefined offset and fsockopen() errors

Recommended Posts

hi,

i found a php-function on the internet to validate an email address, but i'm getting some errors.
see the code and the errors below.
anyone any idea with might be going wrong? the function seems to work, but it produces errors in some way.

thnx in advance,

grenouille

[quote]
Notice: Undefined offset: 1 in ... on line 12

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in ... on line 20

Warning: fsockopen(): unable to connect to :25 ... on line 20

[/quote]

[code]
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;
      }
  }
}
[/code]

Share this post


Link to post
Share on other sites
i found a solution myself. i thought i should post it. it is not actually a solution.
i just put an @ before the list and fsockopen functions so the errors are no longer shown.

[code]
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;
      }
  }
}
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.