AbirBk
AbirBk

Reputation: 21

Verify email address existence with ionic, cordova or javascript

I'm working on my project using ionic framework, how can I check if an email address exists? (not only a correct syntax but it exists online).

I am using ionic 1.7

login.html

<form name="loginForm" ng-controller="loginCtrl"> <input type="submit" value="LOGIN" ng-click="login()" /> </form>

loginCtrl : still empty

$scope.login = function(){ }

Upvotes: 0

Views: 752

Answers (1)

Mike
Mike

Reputation: 175

Testing if an email address actually exists can be done several ways, one of the simplest being first finding the mail exchanger or mail server, then connecting to it, for example:

nslookup -q=mx techcoders.net

Then using telnet to connect and try to get a valid response for it. For more information you can refer to this link.

You can also use a simple PHP class then call it whenever you need to know if a certain email is valid, for that I'd recommend this, just keep in mind that some servers silently reject test messages so it may not be as reliable.

Finally, the best alternative would be using an existing API to just check the domain instead, the MailTest email domain validation API is what I'm using in all my websites and it's without a doubt the most practical way, so let's say you want to check if a certain domain name is valid, you could do a simple request like this (responses are formatted in JSON):

http://api.mailtest.in/v1/techcoders.net

So finally putting it into something you can use:

$http.get('http://api.mailtest.in/v1/techcoders.net')
.success(function(data, status, headers, config) {
     // check result to know if the data is valid or not
})
.error(function(error, status, headers, config) {
     console.log(status);
     console.log("Error");
});

Hope this helps you!

Upvotes: 1

Related Questions