>>>>> "Cristian" == Cristian Prieto <cristian@clickdiario.com> writes:
Cristian> res = res_query(name, C_IN, T_MX, answer, sizeof(answer));
This incorrectly fails if an address has an "A" record but no "MX"
record. According to RFC 2821 Section 5:
The lookup first attempts to locate an MX record associated with
the name. If a CNAME record is found instead, the resulting name
is processed as if it were the initial name. If no MX records are
found, but an A RR is found, the A RR is treated as if it was
associated with an implicit MX RR, with a preference of 0, pointing
to that host.
So, your function will say "no good" if the domain has an A record but
no MX record, even though the RFC says that's OK and deliverable.
Man, is there a lot of bogus knowledge and cargo culting around this
subject!
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!