You can use Robert's answer and RPK to get the MX record of this domain.
But to complete this task, you will need a DNS server. If you want to find the DNS server of the machine on which your code is running, you can use the following.
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties properties = adapter.GetIPProperties(); if (properties.DnsAddresses.Count > 0) foreach (IPAddress ipAddress in properties.DnsAddresses) dnsServers.Add(ipAddress.ToString(), 53); }
There is a complete solution that will do all the work if you do not want to rewrite everything. Find the static method GetMxRecords .
user333306
source share