-1

Recently I notice that some people register with a false email like "blablabla@blablabla.bla"

i want to check if the email entered in the registration form is valid and exist

and thank you ..

i don' want to send anything :/ when i search i find some thing called Mx record how to use it ?

2 Answers2

4

Send the email address in question an email with a link back to your website. This link should contain a unique token that is tied to the user account in question (or, you can simply add the user's ID to the URL as well, so that you know what account to validate the token against). When the user clicks on it, your site should validate the token. If the token is valid, your application can assume that the email address in question exists and that it belongs to the user. Example link:

http://mywebsite.com/validate.php?user=2934&validate=37dbhjibh8879uhe98098ushy89d3dd3

Where 2934 is the user ID and 37dbhjibh8879uhe98098ushy89d3dd3 is the token that you sent out and need to validate.

When the user is registering, you can check if the email conforms to RFC 822 grammar by using:

if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
     //Valid email!
}
Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66
0

You can if the the domain of the email address entered has a valid MX record using the below code:

checkdnsrr(preg_replace('/^[^@]+@/', '', $emailAddress), 'MX');

But checkdnsrr() doesn't work on Windows platforms

Ramesh
  • 4,223
  • 2
  • 16
  • 24