hi how we can check emails are exists in reality using php.. I want to develop a software to sort out emails address.... but facing some problems any one assist in this matter that what is the idea behind it
It's completely possible, but normally you would check this by querying the email-address and look for a response. Since there are already companies that provide this sort of functionality, it's completely possible, but how, I don't know, since I've never bothered with actually checking if an email actually exists. With todays possibilities of one-time emails, random Gmail/Hotmail/Yahoo-accounts, etc. checking to see if an email is actually active when someone signs up or something similar, is kinda moot. Of course, washing email-lists is another issue alltogether, so there it might have some merit.
Easiest way to just make sure that the email is actually in a valid format is to use filter_var: $email = $_GET['email']; if(filter_var($email, FILTER_VALIDATE_EMAIL)){ return "Valid email!"; }else{ return "Not a valid email, sucka."; } PHP:
Checking the account actually exists is VERY hard -- as others have already said the best you can usually hope for is to make sure the format of the e-mail is correct, and that the domain in question has a valid A or MX record. This is the routine I use for checking mails. A user from another forums and I brainstormed on this one. function isValidEmail($address) { if (filter_var($address,FILTER_VALIDATE_EMAIL)==FALSE) return false; /* explode out local and domain */ list($local,$domain)=explode('@',$address); $localLength=strlen($local); $domainLength=strlen($domain); return ( /* check for proper lengths */ ($localLength>0 && $localLength<65) && ($domainLength>3 && $domainLength<256) && ( checkdnsrr($domain,'MX') || checkdnsrr($domain,'A') ) ); } Code (markup): Checks that the address is properly formed, proper lengths (something filter_var fails to do), and makes sure the domain actually exists.
yes it help me but there i desire to check the all emails are active or not , However thanks for response
That will actually allow emails that are too long. Granted, the total length of an email address, or rather, the proper max length of an email-address, have been debated for years, but the concensus is that it's 254 characters total - hence, a total of 65 + @ + 256 will greatly exceed that. Have a look at http://tools.ietf.org/html/rfc5321. I suggest adding a check for total length as well. I think perhaps that the minimum domainLength could also be altered slightly - given that the minimum TLD is three characters (.XX) and that the minimum domain name length is 2, I would guess that checking for anything less than 5 would do (yes, I'm aware that ending an email-address in @.com for instance is legal, but not very much used...). Unfortunately, checking for replies from the mailserver often takes too long, and unfortunately, doesn't always contain the correct return codes :/
You're miss-reading 5321... and I quote: Local-part is everything before the @, Domain is everything AFTER. The reason it's 255 octets (bytes) is one extra octet is reserved as a stop byte or length limited byte so it fits in a 8 bit delimited string. A clearer explanation can be found in RFC 3696: http://tools.ietf.org/html/rfc3696#page-6 ... and I quote: Also you misread my code -- the lengths checked for are 64 and 255, NOT 65 and 256, hence the < instead of <= 320 is the total as specified, no clue where that idiotic and nonsensical 254 number came from apart from parrot quoting people who don't know enough about the specifications to be opening their mouths on the subject. Near as I can tell it's 100% fictional BS if one bothers reading RFC's 5321, 5322, 3696, 6531, etc, etc... Or should I say comprehending it, since there's a mile of difference between reading something and comprehending it. I suspect the misunderstanding is akin to the nonsense where people try to claim XHTML should be able to do <div /> because they fail to grasp what the specification means when it says an 'empty element' -- because <div></div> is NOT an empty element by the specification. EMPTY elements are ones that CANNOT contain content, not ones that do not... Admittedly, the legalese used in any of the specifications seems carefully crafted to make sure only lawyers and the people who wrote it have a chance in hell of grasping any of it.
Take a look here, please: http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690 It's correct that the separate values is 64 and 255, but the TOTAL value cannot (or, should not, since not all mail-servers are created equal) exceed 254. However, I'm reading RFCs now, I haven't actually tested this. Maybe I should. That would however involve registering a domain-name which maxes out the length... The fun bit about RFCs is that there are so MANY of them - and they're all SLIGHTLY different, albeit describing the exact same issue or function. Fun times.
2821 is obsolete, see the obsolete messages on 5321. There are a LOT of RFC, usually the number is a good indicator of which one to follow -- older it is, check for a newer one that obsolete's it.
Neither one of you will admit to being wrong, because you are both nerds. And nerds are never wrong. With that said, not all email servers are created equal and not all follow the standard. As long as you are checking for an approximate max length that should be good enough to validate an email address. ThisIsA170CharacterDomainNameWhichIsLessLikelyToBeUsedByAnyone_IActuallyWouldFlagThisAsInvalidEvenThoughItsValidByRFCStandards_ICantBelieveYouGuysAreArguingAboutThis.com Setting a REAL WORLD character cap on an email domain name increases the quality of the validation. I can't see how checking to make sure a DOMAIN does not exceeds 254 characters is anything but counter productive when ATTEMPTING to validate the authenticity of an email address.
I have no problem admitting I'm wrong, it's just that this have been debated "forever". However, it's mostly a purely theoretical debate, as most hosts sets a limit on domain name length at 64ish characters.
first of all you just have to check the status of the emails,whether they are activate or in a valid form....
beven - for your ORIGINAL question - how to check if an email is really active: I know only one way that all of us are familiar with - send an activation email