Jump to content

Undefined offset and fsockopen() errors


grenouille

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]
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.