Mail adress validation – MX records

Notice: This thread is very old.
priman
Member | 7
+
0
-

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.

Filip Procházka
Moderator | 4668
+
0
-

@priman that's actually a very good Idea, but I don't think it should be directly in framework (or at least not turned on by default). Maybe as an addon it would be nice.

Would you be interested in creating such addon?

bckp
Member | 12
+
0
-

I need such addon in 1Q2014, so if nobody writes this addon, i will do it :)

Milo
Nette Core | 1283
+
0
-

@priman @Filip Procházka It could be part of validators.

priman
Member | 7
+
0
-

Modified validator with checking MX records is here: https://github.com/…lidators.php

But now we need discuss if it should be part of validator or not. Good point from github is “validation” vs. “verification”.

blindAlley
Member | 31
+
0
-

OT: I like that repository name – nechutny/nette

petr.pavel
Member | 535
+
+1
-

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.