There are several types of DNS records, including the following:
- A (address) records map a domain name to an IP address, e.g. the A record for jonallen.info is 212.69.202.117.
- CNAME records are aliases - mail.jonallen.org.uk is an alias for www.jonallen.org.uk (they are physically the same machine).
- MX (mail exchange) records indicate the host which handles email for that domain - this does not have to be related to any other servers (e.g. web). Normal convention is to use email in the form user@domain.tld wheras webservers are usually called www.domain.tld. It is possible to have MX records for domains without A or CNAME records (either of which is required for a name to resolve to an IP address), this is causing your problem with gethostbyname().
Several MX records can be set for a domain name, each with a priority value. For example, if I have an MX 5 record and an MX 10 record, email will be sent through the MX 10 host if the MX 5 machine goes down.
Have a look at http://www.dns.net/dnsrd/ for more information (try the 'DNS resource record types' link).
Cheers,
JJ