Checking existence of email address

北慕城南 提交于 2021-02-04 21:18:05

问题


I'm developing a web application with Chat Support, and so far, I've been using JQuery validation to check whether the input text is a well formatted email address.

But that doesn't seem to fulfill its purpose.

For example:

  1. Entering a working and legitimate email address such as myname@gmail.com
  2. Entering a fake/random email address such as abcd@something.com

Both are accepted into the field as valid.

So is there any way to detect whether the specified email address exists or not in real-life, by using PHP (or any other) without sending the user, a click-to-confirm email?

I've tried the SMTP method discussed in the other question, but unfortunately, the server returned error for all Email addresses, even legitimate ones. I think they have prevented enumeration for security purposes.

Any help would be greatly appreciated. :)


回答1:


No, it's not possible to reliably check if email address actually exists withotu sending an actual email. All you can do by yourself is to check syntax of email address and check of domain name exists.

To check email address syntax:

filter_var($email, FILTER_VALIDATE_EMAIL)

To check A and MX records:

checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")

Next step is to send actual email with confirmation URL or confirmation code.



来源:https://stackoverflow.com/questions/34564281/checking-existence-of-email-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!