Jump to content


Photo

Detecting if an email is genuine


  • Please log in to reply
5 replies to this topic

#1 Xurion

Xurion
  • Members
  • PipPipPip
  • Advanced Member
  • 259 posts

Posted 10 October 2006 - 08:45 AM

If I have an email address field that the user fills in, what is the best way to detect if that email is real?

Do I simply detect if there is an @ symbol there? Or is there another way to detect if it is genuine?

Thx in advance  :)

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 10 October 2006 - 09:06 AM

Here is what I use, most of the time:

$email = $_POST['email'];
$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$";
if (!eregi($regex,$email)) {
  echo "Invalid Email!";
}
else {
  //do whatever
}


#3 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 10 October 2006 - 09:31 AM

what if you want to check if the email address is really existing?
Registered Linux User #399942
Ubuntu User #14134
--
my blog

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 10 October 2006 - 09:37 AM

Do you mean something like:

if (empty($_POST['email'])) {
  echo "No email was entered";
}
else {
  //do whatever
}
?


#5 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 10 October 2006 - 09:41 AM

nope i mean how can you check if the domain entered really exist

ex. vbnullchar@yahoo.com <- this is existing
someone@somewhere.com <- can u determine if somewhere.com really exist..


Registered Linux User #399942
Ubuntu User #14134
--
my blog

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 09:42 AM

Yes, you can attempt to resolve the name first by performing an MX Lookup.

For further details try googling "Validate Email" +Lookup

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users