- Member | 7
I'm not sure in it (can be good reason, why it isn't already implemented),
but I think, that email adress validation should also check for domain's MX
records – for example via getmxrr(). It help with lots typos in adress.
Function getmxrr() is supported from PHP 5.3 on Windows too, so it isn't problem. Maybe it cost too much time (network latency), but it increase number of valid adresses.
- Backer | 501
I've just spent some time playing with domain name validation for e-mails. It's a mess.
- MTA will (in most cases) deliver to a domain even though it has no MX
record – it will use A record
So you can't kick out e-mails just for not having a MX record.
- getmxrr, checkdnsrr and other built-in PHP functions are very slow (seconds!)
- domain validity cannot be decided based on return value of getmxrr only, you have to use the second parameter and process returned MX values (0.0.0.0, uk-net-wildcard-null-mx.centralnic.net, maybe more)
- when resolving domain name using built-in functions you sometimes have to translate with idn_to_ascii() – but not always
- whois-based methods are difficult to implement because you'd have to know which whois server to ask
Because I was running out of time, I settled for checkdnsrr(). However, due to its slowness, I certainly don't think it should be a part of the default Form::EMAIL validation rule. Yes for having it in Nette but only as a separate rule.
These guys seem to be serious about the validation but they too use getmxrr() when available. If not available, they use PERL Net::DNS module port.
A proper solution should IMHO call a third party utility (nslookup/host) and implement the DNS protocol directly (like Net::DNS) as a fallback.