开发者

How to check whether an email id exists or not?

How to check whether an email id exist开发者_如何学编程s or not using PHP? and to get information about the owner of the email id? is it possible to get the information about the owner of the email id? do have to work with some protocols like POP? Please help me.


There is no 100% guaranteed way of knowing if an email address is valid without sending an email and having the user respond in some way. There are checks you can do to increase the chances of knowing if an email address is valid or not. You can do a DNS lookup and see if the domain has an MX record. There are also parts of the SMTP protocol you can use, but nothing mandates that an SMTP server will respond to these commands. Centralops.net provides a product that can help, but again, it isn't guaranteed.

If there was a sure way of handling this, then why would virtually every site that has a registration feature require you to respond to an email in some way? The question isn't meant to be a snide one; I'm just hoping it helps you see that other sites have not been able to perform the very same check you are asking for.

HTH


Lets say a user submits the following email address:

  • stackuser@stackoverflow.com

The checks you would want to perform in order are like so:

  • Is the address valid
  • Does the domain run a mail server / MX Records
  • Is it blacklisted

Firstly within PHP you can validate an email by using filter_var like so:

$is_valid = filter_var("stackuser@stackoverflow.com",FILTER_VALIDATE_EMAIL);

Secondly you would want to check if the domain runs a email server, to do this you can check the dns records for MX like so:

$has_dns_mx_record = checkdnsrr("stackoverflow.com","MX");

You might also want to open the port on the domain like so:

$socket = fsockopen("stackoverflow.com", 25);
$mail_running = (bool)$socket;
fclose($socket);

You can also check to see if the SMTP Server responds with a 550, i.e email does not exist, like so:

SEND > helo hi
250 stackoverflow.com

SEND > mail from: <youremail@yoursite.com>
250 2.1.0 Ok

SEND > rcpt to: <stackuser@stackoverflow.com>
> 550 5.1.1 <stackuser@stackoverflow.com>: Recipient address rejected: User unknown in local recipient table

Looking at the above you can send commands to a valid smtp server such as helo > mail from <...> and check the 550 response.

Take a look here for some response codes: http://www.greenend.org.uk/rjk/2000/05/21/smtp-replies.html

Also you should take note of @slebetman's comment stating that a small percentage of mail > servers are configured to respond 550 to prevent the sniffing out of valid email addresses.

The black list check is pretty simple, you would just find a decent DNSBL Server that provides a gateway for you check check the domain to see if it has been blacklisted, if it has the email may well be valid and active but has been marked as spam, therefore its an untrusted email and you should request an alternative email address to authorize against

These are some of the validation techniques used to validate an email address, now there is plenty more validation methods but these are a few of the main ones.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜