|
Actually this went around the list a month or two ago. IIRC, you check for an MX record first. If it exists you MUST use it. If is doesn't exist, you SHOULD check for an A record w/the domain name. If it exists you use it. If no A record exists then you're toast.
That's not precisely true. If a CNAME record exists, then that might point to a different A record. It's possible (though, discouraged) to route e-mail using a CNAME record.
So, technically, this is the process:a) Look up the MX records. If one exists, make sure it points to a valid A record (or a CNAME record that points to an A record) as long as one MX record is valid, the domain is good.
b) If no MX records exist, try looking up an A record for the original domain. If that works, the domain is good.
c) If no A record exists, try looking up the CNAME record. If that works, resolve the A Record that the CNAME record points to. If that works, the domain is good.
This leaves you with a process where if a domain lookup for any of the A, CNAME or MX records works, the domain is good. At that point, it doesn't matter which order you do them in, because ANY of them being correct will mean that the domain is correct.
And that's what my program (in the article you referenced) does. That's EXACTLY what it does.
Now, if you're going to actually CONNECT to these, then the order of the lookups becomes important. My program doesn't do that, so it doesn't matter.
If you're assertion is that "test.com" shouldn't be valid because e-mail for test.com is supposed to be sent to "testcentral.com", neither Walden's method nor mine will detect this. The only difference between the two methods, is that I checked the A and CNAME records first instead of second. No matter what order you check them in, it'll still think "test.com" is valid, because the A record lookup for TEST.COM will still work.
The only way you could ACTUALLY tell that test.com isn't a valid domain for e-mail is if you tried actually connecting to TEST.COM as an SMTP server. And that's not foolproof either, because if the SMTP server happens to be down at the moment, or if traffic is too high going to it, it might not respond in spite of being a valid e-mail address. An actual SMTP server will queue up the message and keep retrying for a few days, but you obviously can't do that in the case of verifying that the domain is valid.
So I don't think you'll be able to solve the problem of test.com vs. testcentral.com.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.