简体   繁体   English

使用ionic,cordova或javascript验证电子邮件地址是否存在

[英]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? 我正在使用ionic框架进行项目,如何检查电子邮件地址是否存在? (not only a correct syntax but it exists online). (不仅是正确的语法,而且在线存在)。

I am using ionic 1.7 我正在使用离子1.7

login.html login.html

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

loginCtrl : still empty loginCtrl:仍然为空

$scope.login = function(){ }

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. 然后使用telnet进行连接,并尝试获得有效的响应。 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. 您还可以使用一个简单的PHP类,然后在需要知道某封电子邮件是否有效时调用它,为此,我建议您这样做 ,但请记住,某些服务器会默默地拒绝测试消息,因此它可能不那么可靠。

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): 最后,最好的选择是使用现有的API来仅检查 ,而MailTest电子邮件域验证API正是我在所有网站中使用的API,毫无疑问,这是最实用的方法,所以假设您要检查某个域名是否有效,您可以执行以下简单请求(响应格式为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! 希望这对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM