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.4 build 677 for .NET 4.5
public string[] GetMXHosts(
	string 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.
MailBeeInvalidArgumentExceptiondomain is a null reference (Nothing in Visual Basic).
MailBeeExceptionAn error occurred and ThrowExceptions is true.
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).
This sample retrieves the list of DNS MX server names accepting mail for "" domain.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
    static void Main(string[] args)
        Smtp mailer = new Smtp();
        string[] hosts = mailer.GetMXHosts("");
        foreach (string host in hosts)
See Also