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@stackoverflow.com
  • 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
  • 域是否运行邮件服务器/ 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@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:

第二,你要检查域名是否运行电子邮件服务器,要这样做,你可以检查MX的dns记录如下:

$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:

您还可以检查SMTP服务器是否响应550 i。电子邮件不存在,比如:

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.

查看上面的内容,您可以向有效的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.

这些是用于验证电子邮件地址的一些验证技术,现在有很多验证方法,但这些只是其中的几个主要方法。

更多相关文章

  1. Yii2之发送电子邮件
  2. 如何在php imap函数中看到看不见的电子邮件
  3. TextView在单击时发送电子邮件

随机推荐

  1. C# 数组作为参数传递出现的问题解决
  2. C#中引用类型之特例string的详细介绍
  3. C#实现Json序列化删除null值的方法实例
  4. c#如何生成二维码的示例分享
  5. C#如何通过对象属性名修改值的实例
  6. C#中Builder生成器模式解决配置电脑的问
  7. c#接口的问题的解决办法详解
  8. Asp.net Mvc表单验证气泡提示效果展示
  9. .NET中core如何利用Redis发布订阅的实例
  10. .Net实现微信JS-SDK分享功能代码展示