How to check whether an email id exists 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.
如何使用PHP检查电子邮件id是否存在?获取关于电子邮件id的所有者的信息?是否有可能获得关于电子邮件id所有者的信息?必须使用一些协议,比如POP吗?请帮助我。
2 个解决方案
#1
12
Lets say a user submits the following email address:
假设用户提交以下电子邮件地址:
- stackuser@*.com
- stackuser@*.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
- 域是否运行邮件服务器/ MX记录
- Is it blacklisted
- 它是被列入黑名单
Firstly within PHP you can validate an email by using filter_var
like so:
首先,在PHP中,您可以使用filter_var这样验证电子邮件:
$is_valid = filter_var("stackuser@*.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:
第二,你要检查域名是否运行电子邮件服务器,要这样做,你可以检查MX的dns记录如下:
$has_dns_mx_record = checkdnsrr("*.com","MX");
You might also want to open the port on the domain like so:
您可能还希望在域上打开端口:
$socket = fsockopen("*.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:
您还可以检查SMTP服务器是否响应550 i。电子邮件不存在,比如:
SEND > helo hi
250 *.com
SEND > mail from: <youremail@yoursite.com>
250 2.1.0 Ok
SEND > rcpt to: <stackuser@*.com>
> 550 5.1.1 <stackuser@*.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.
查看上面的内容,您可以向有效的smtp服务器发送命令,比如来自<…>并检查550响应。
Take a look here for some response codes: http://www.greenend.org.uk/rjk/2000/05/21/smtp-replies.html
这里有一些响应代码: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.
您还应该注意@slebetman的评论,该评论指出,一小部分邮件>服务器配置为响应550,以防止嗅出有效的电子邮件地址。
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
黑名单检查很简单,你就会找到一个体面的DNSBL服务器提供了一个为你检查检查域网关是否已被列入黑名单,如果电子邮件很可能是有效的和积极但已被标记为垃圾邮件,因此它不受信任的电子邮件和你应该请求另一个电子邮件地址授权
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.
这些是用于验证电子邮件地址的一些验证技术,现在有很多验证方法,但这些只是其中的几个主要方法。
#2
13
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.
在不发送电子邮件和让用户以某种方式回复的情况下,无法100%保证知道电子邮件地址是否有效。你可以做一些检查来增加知道一个电子邮件地址是否有效的机会。您可以执行DNS查找并查看域是否有MX记录。您还可以使用SMTP协议的一些部分,但是没有任何命令要求SMTP服务器响应这些命令。Centralops.net提供了一种可以提供帮助的产品,但同样不能保证。
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
HTH
#1
12
Lets say a user submits the following email address:
假设用户提交以下电子邮件地址:
- stackuser@*.com
- stackuser@*.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
- 域是否运行邮件服务器/ MX记录
- Is it blacklisted
- 它是被列入黑名单
Firstly within PHP you can validate an email by using filter_var
like so:
首先,在PHP中,您可以使用filter_var这样验证电子邮件:
$is_valid = filter_var("stackuser@*.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:
第二,你要检查域名是否运行电子邮件服务器,要这样做,你可以检查MX的dns记录如下:
$has_dns_mx_record = checkdnsrr("*.com","MX");
You might also want to open the port on the domain like so:
您可能还希望在域上打开端口:
$socket = fsockopen("*.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:
您还可以检查SMTP服务器是否响应550 i。电子邮件不存在,比如:
SEND > helo hi
250 *.com
SEND > mail from: <youremail@yoursite.com>
250 2.1.0 Ok
SEND > rcpt to: <stackuser@*.com>
> 550 5.1.1 <stackuser@*.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.
查看上面的内容,您可以向有效的smtp服务器发送命令,比如来自<…>并检查550响应。
Take a look here for some response codes: http://www.greenend.org.uk/rjk/2000/05/21/smtp-replies.html
这里有一些响应代码: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.
您还应该注意@slebetman的评论,该评论指出,一小部分邮件>服务器配置为响应550,以防止嗅出有效的电子邮件地址。
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
黑名单检查很简单,你就会找到一个体面的DNSBL服务器提供了一个为你检查检查域网关是否已被列入黑名单,如果电子邮件很可能是有效的和积极但已被标记为垃圾邮件,因此它不受信任的电子邮件和你应该请求另一个电子邮件地址授权
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.
这些是用于验证电子邮件地址的一些验证技术,现在有很多验证方法,但这些只是其中的几个主要方法。
#2
13
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.
在不发送电子邮件和让用户以某种方式回复的情况下,无法100%保证知道电子邮件地址是否有效。你可以做一些检查来增加知道一个电子邮件地址是否有效的机会。您可以执行DNS查找并查看域是否有MX记录。您还可以使用SMTP协议的一些部分,但是没有任何命令要求SMTP服务器响应这些命令。Centralops.net提供了一种可以提供帮助的产品,但同样不能保证。
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
HTH