Retrieves the list of hosts willing to accept mail for the given domain.
Namespace: MailBee.SmtpMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public string[] GetMXHosts(
string domain
)
Public Function GetMXHosts (
domain As String
) As String()
Parameters
- domain
- Type: SystemString
The domain to get the list of MX hosts for.
Return Value
Type:
StringThe 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 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);
}
}
}
Imports System
Imports MailBee
Imports MailBee.SmtpMail
Class Sample
Shared Sub Main(ByVal args() As String)
Dim mailer As Smtp = New Smtp
mailer.DnsServers.Autodetect()
Dim hosts() As String = mailer.GetMXHosts("hotmail.com")
Dim host As String
For Each host In hosts
Console.WriteLine(host)
Next
End Sub
End Class
See Also