How do I lookup DNS MX, TXT, etc. records?

In Ruby, I use Resolv::DNS to do this. Is there a Crystal Library or Shard do to this? I’ve spent hours searching and reading source code, even down into LibC.

For the Socket::Addrinfo class, there seems to be no way to specify the record name (A, AA, CNAME, MX, TXT, etc), and only returns the A record. If I specify a “service” of “smtp” or 25 (for email), it returns the A record for the domain instead of the MX record address (which identifies the server to send email to):

Socket::Addrinfo.tcp(“”, “smtp”).inspect #=> IP Address of A record

Thanks in advance!

1 Like

Refer to Crystal Shards, Tools and Tutorials



Thank you again! I saw that shard discovery section, but thought they were all like “awesome shards”. Now I am illuminated, and found a shard to use!