Looking for an MX Record Using C #?

How to find MX record for mail server in C #?

+6
c # smtp mx-record
source share
6 answers

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 .

+5
source share
+3
source share

Take a look at this DNS resolver project at codeproject.com . There is a Resolver class in the library that contains a method called Query that you can use to write after recording MX.

+3
source share
+2
source share

I just wrote a simple asp.net generic handler to do the job of finding mx entries that you can use to encode a Windows application.

General handler for finding MX records

0
source share

The NMail project contains a DNS client under trunk / NMail.DnsClient. The project is licensed under Apache.

0
source share

All Articles