The dig command is used for querying DNS information. To retrieve the MX records for a domain (which indicate where emails should be routed), the command dig mx foo.com is used. This returns the mail servers associated with the domain, including their priority levels.