Page 1 of 1

Socket/Check Mail problem

Posted: Sun Jul 24, 2005 6:27 pm
by bla5e
The Function:

Code: Select all

<?php
function checkEmail($email) 
{
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $e)) 
   {
      return FALSE;
   }

   list($Username, $Domain) = split("@",$e);

   if(getmxrr($Domain, $MXHost)) 
   {
      return TRUE;
   }
   else 
   {
      if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
      {
         return TRUE; 
      }
      else 
      {
         return FALSE; 
      }
   }
}
?>

The Code:

Code: Select all

<?php
if(checkEmail($email) == FALSE) {
   			echo "E-mail entered is not valid.";
		} else {
   			echo "E-mail entered is valid.";
		}
?>
$email = from a previous page/form



The Error:
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/steve/public_html/teamexileonline/index.php on line 17

Warning: fsockopen(): unable to connect to :25 in /home/steve/public_html/teamexileonline/index.php on line 17
Line 17 = <?php if(fsockopen($Domain, 25, $errno, $errstr, 30)) ?>

Re: Socket/Check Mail problem

Posted: Mon Jul 25, 2005 3:37 am
by hopfateam
bla5e wrote:The Function:

Code: Select all

<?php
function checkEmail([b]$email[/b]) 
{
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", [b]$e[/b])) 
   {



[/quote]

Mistake should be using $e instead of function´s variable $email, which let´s u receive a wrong parameter $Domain which is then used in line 17

Posted: Mon Jul 25, 2005 4:45 am
by onion2k
One small thing, and it's probably just me, but you could be a little more courteous than just posting some code and an error and expecting people to fix it for you. A "please can you help?" would be nice.

As it happens your email matching regex is wrong. Even if you correct the error in the regex itself it still wouldn't match my email address. Check the regex folder on here to find a better one.

Posted: Mon Jul 25, 2005 7:33 pm
by bla5e
onion2k wrote:One small thing, and it's probably just me, but you could be a little more courteous than just posting some code and an error and expecting people to fix it for you. A "please can you help?" would be nice.

As it happens your email matching regex is wrong. Even if you correct the error in the regex itself it still wouldn't match my email address. Check the regex folder on here to find a better one.
where can i find the regex folder on here, please :-)

Posted: Mon Jul 25, 2005 9:41 pm
by Roja
bla5e wrote: where can i find the regex folder on here, please :-)
viewforum.php?f=38

And for the definitive RFC-compliant regex, you can grab a GPL-licensed validateemail function:

http://svn.gna.org/viewcvs/blacknova/tr ... iew=markup