How to validate a gmail address in Java

北城以北 提交于 2019-12-24 00:26:15

问题


How can I verify if a given gmail address is valid or not?

I'm not asking for a script to check validation nor any regular expression. I only need to know if a person put a valid gmail address in a verify box. Some code which checks Google's database to see if it is a valid gmail address. The same as when we register a new gmail address and it shows a message saying the gmail address already exists. If it is possible to do so with some Google API for Java? I would like to use it in GAE.


回答1:


If a person puts a gmail address in a "verify" text-box then what code can I use to check google's database and tell me whether this is a valid ID?

I hope there is no way because gmail should not go out of their way to make it easy to harvest lists of email addresses to spam:

A Directory Harvest Attack or DHA is a technique used by spammers in an attempt to find valid/existent e-mail addresses at a domain by using brute force. The attack is usually carried out by way of a standard dictionary attack, where valid e-mail addresses are found by brute force guessing valid e-mail addresses at a domain using different permutations of common usernames. These attacks are more effective for finding e-mail addresses of companies since they are likely to have a standard format for official e-mail aliases (i.e. jdoe@example.domain, johnd@example.domain, or johndoe@example.domain).

Any API that lets you tell whether a string is a gmail address that points to a live account would simply make it easier for spammers to spam that user.


If not then what are secure way to validate?

Send them an email with a URL that they can click to confirm that they own the email address.

The link should contain a nonce that you store in a database with the email addy or some information you've signed so you know it came from you.

This kinds of account verification is pretty standard.



来源:https://stackoverflow.com/questions/13313877/how-to-validate-a-gmail-address-in-java

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