SmtpGetMXHosts Method
Retrieves the list of hosts willing to accept mail for the given domain.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public string[] GetMXHosts(
	string domain
)

Parameters

domain
Type: SystemString
The domain to get the list of MX hosts for.

Return Value

Type: String
The array of string names of hosts willing to accept mail for the given domain, or LocalSmtpMXServerName if domain is an empty string, or a null reference (Nothing in Visual Basic) if an error occurred.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptiondomain is a null reference (Nothing in Visual Basic).
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks
This method makes DNS MX query to the servers listed in DnsServers collection regarding domain. The method will return the domain name itself if the DNS query reports the given domain contains A record only (i.e. the given domain is willing to accept mail for itself). MX records are returned accordingly their priorities (higher priority listed first).
Examples
This sample retrieves the list of DNS MX server names accepting mail for "hotmail.com" domain.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
{
    static void Main(string[] args)
    {
        Smtp mailer = new Smtp();
        mailer.DnsServers.Autodetect();
        string[] hosts = mailer.GetMXHosts("hotmail.com");
        foreach (string host in hosts)
        {
            Console.WriteLine(host);
        }
    }
}
See Also