How can you check whether domain exists or not in Java?

前端 未结 5 1220
死守一世寂寞
死守一世寂寞 2020-12-17 20:57

Suppose my email address is xyz@yahoo.com and I want to check if yahoo.com is a valid domain or not.

Can anyone tell me which Java API I ca

5条回答
  •  时光取名叫无心
    2020-12-17 21:06

    Another possibility is to check the MX of the entered domain.

    http://www.mxtoolbox.com/SuperTool.aspx

    It is not Java API, but you can always parse the HTML response.

    It means if the provider of the mail service is not blacklisted it could be safe and a real address.

    But as already said, some server could always define security restriction to such service.

    Another point, some services exist to provide temporary emails (mailinator.com, jetable.org, and so on...) You have to check these domains as well if you want to prevent a user to register with such an email.

    UPDATE

    Google provides a DNS check site which seems to be free.

    An example: https://dns.google/resolve?name=amazon.com&type=MX returns a page with the following JSON:

    {
      "Status": 0,
      "TC": false,
      "RD": true,
      "RA": true,
      "AD": false,
      "CD": false,
      "Question": [
        {
          "name": "amazon.com.",
          "type": 15
        }
      ],
      "Answer": [
        {
          "name": "amazon.com.",
          "type": 15,
          "TTL": 724,
          "data": "5 amazon-smtp.amazon.com."
        }
      ]
    }
    

提交回复
热议问题