Getting a MX record from DNS

I have a program which needs to send an email periodically to a
user-specified address. I would like for the user to be able to
specify the destination email address only and not have to also
specify the email server. To do this I’ll need to send a MX query to
the DNS server for the email address’s domain. The DNS code in the
rabbit semi libraries only support DNS IP address queries - the
_DNS_QUERY_MX type is unsupported.

Has anyone had experience with modifying the existing DNS code or
writing your own to handle MX queries? Is there existing source code
out there for this?