Implementations of the DNS protocols must not place any restrictions on the labels that can be used.
In particular, DNS servers must not refuse to serve a zone because it contains labels that might not be acceptable to some DNS client programs.
There are ways of going even further and making sure that, when you talk to the recipient’s SMTP server, that it responds accordingly, but that’s one step too far for me right now.
;) Can easily be extended to only check for nameservers and such … Note that this does not work in Windows/BSD systems, but the PEAR Net_DNS package can provide this for those platforms. Stepping around the validation issue for a minute, if a customer doesn’t want to give you a valid e-mail/domain is that someone you really want to be doing business with?
For example, did you know "♡.com" is a valid domain name? To validate the domain name, you need to let pass the validation.
Is there a quick and dirty way to validate if the correct FQDN has been entered? Note that a registerable TLD can have more than one component, such as "co.uk". The rules are designed to prevent such things as mixing characters from left-to-right and right-to-left sets. regex is always going to be at best an approximation for things like this, and rules change over time.
Finally the underscore is invalid everywhere in all labels.
The tld cannot begin with the number * The length of the domain or subdomain can be between 1 and 63 characters and for tld it can be 2 to 63 characters * Total length of domain name should not exceed 256 characters * * @param domain Name - String value for domain that needs to be validated * @return true if domain name matches with the regex pattern else false */ public static boolean is Valid Domain Name(String domain Name) ^ # Anchors to the beginning to the string. A regular expression for matching valid domain names.This regex seeks to support all domains with TLDs listed on including IDNs.Keep in mind there is no DNS server or Internet connection, so validation has to be done via regex/awk/sed. the above regex was written with the following in mind and is specific to hostnames- Hostnames are composed of a series of labels concatenated with dots. You can check whether TLD part is valid by keeping a list of your own TLDs (which will need to be kept up-to-date) but other than that I guess you're out of luck :) It's harder now, what with internationalized domain names and several thousand (! The easy part is that you can still split the components on ".". There's a site for that: https://publicsuffix.org/list/effective_tld_You only need to check the ICANN-recognized ones. The rules for Unicode are very complex, and are given in RFC5890.