adv Posted June 2, 2008 Share Posted June 2, 2008 is there a way to check if a email exists? on yahoo works because if the id is not taken it will show and with curl u can easly take that result but on gmail it doesn`t .. it just only say u put in wrong password or any id .. is there another way of checking if the email exists on domains like gmail ?? thanks in advance p.s. my english lets me down Quote Link to comment Share on other sites More sharing options...
Lodius2000 Posted June 2, 2008 Share Posted June 2, 2008 i found this earlier today, its not quite what you are looking for but page 2 does check to see if email is configured for that dns pretty cool Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 2, 2008 Share Posted June 2, 2008 @lodius: You didn't post anything @adv: Are you trying to validate an email for a form submission? If you're trying to make sure that someone typing in an email address for a form, IMO you're creating too much work for yourself. Just let them type in an address and check to see if it's formatted properly. I've used this for a while without any problems. I see people posting email regex all the time and it fails for one of my family member's addresses. preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(([,]|[,])\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*$/", $email) Quote Link to comment Share on other sites More sharing options...
adv Posted June 2, 2008 Author Share Posted June 2, 2008 yes from a form submission i know u can use preg_match to check for @ .. yata yata but i was just wondering if there a way to check for real like i said on the top about yahoo and gmail... that is what i wanna find out Quote Link to comment Share on other sites More sharing options...
adv Posted June 2, 2008 Author Share Posted June 2, 2008 and another question i dont wanna open a new thread if i use this function check($value) { if (empty($value) || strlen($value) < 4) return true; return false; } i don`t use the curly brackets inside the function in the if statement . is it something bad ? it works harder ? security problems ?? or does it works good ? Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted June 2, 2008 Share Posted June 2, 2008 The only time you need those brackets is when you have more that one statement that falls under the loop or conditional Quote Link to comment Share on other sites More sharing options...
haku Posted June 2, 2008 Share Posted June 2, 2008 That is true. However, code is harder to read without the curly braces, which results in a higher potential for harder to find errors in the future. So it's good to use them. As to your initial question, I don't believe that you can check if an email address exists with 100% accuracy, but I use this script, and it has worked well for me: function checkEmail($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } list($Username, $Domain) = split("@",$email); if(!checkdnsrr($Domain, 'MX')) { return false; } return true; } I've never had any problems, and it has caught everything I have ever tried throwing at it. See if it works for you. It definitely catches non existent domains, but it doesn't seem to catch non-existent email addresses, although its been a while since I tested it. Quote Link to comment Share on other sites More sharing options...
adv Posted June 2, 2008 Author Share Posted June 2, 2008 thanks alot haku and angel :* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.