How to get mx records for a dns name with System.Net.DNS?

前端 未结 7 1298
难免孤独
难免孤独 2020-11-29 00:34

Is there any built in method in the .NET library that will return all of the MX records for a given domain? I see how you get CNAMES, but not MX records.

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 01:17

    You can use this open source library to do almost any kind of query you would usually need.

    Usage:

    DnsClient dnsClient = new DnsClient();
    string mxDomain = dnsClient.ResolveMX("example.com");
    string mxDomainIP = dnsClient.ResolveMX("example.com", true);
    string mxDomainIPv6 = dnsClient.ResolveMX("example.com", true, true);
    

提交回复
热议问题