One note about using gethostbyname() for checking email address domains:
If the name doesn't resolve, follow up with getdnsrr() and make sure they don't have an MX entry before returning an error.
It is possible for a domain name not to have an A record, but still have an MX entry.