SmtpDnsServers Property
Gets the DnsServerCollection object containing the list of DNS servers to be used for DNS MX lookup.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public DnsServerCollection DnsServers { get; }

Property Value

Type: DnsServerCollection
The DnsServerCollection object containing the list of DNS servers to be used for DNS MX lookup in direct send mode (without dedicated SMTP relay server).
Remarks

MailBee can auto-detect which DNS servers are available in the system. The developer can use Autodetect method to retrieve DNS settings from OS or from the config file.

If DnsServers collection is non-empty and SmtpServers collection is empty, Send method will send messages in direct send mode. For each unique domain in the list of the message recipients domains (e.g. host1, host2, host3 if the recipients are joe@host3, kate@host1, bill@host2, tanya@host3, rob@host2), the component makes a query to the DNS server to get the name of the SMTP server which accepts mail for the corresponding domain (for instance, mx.host1, smtp.host2, mx-5.large-isp for host1, host2, host3), and then sends mail directly to these servers. If more than one SMTP server accepts mail for the given domain, the highest-priority server will be tried first. If it fails, other servers will be tried accordingly their priorities.

If multiple DNS servers specified, MailBee will distribute load between the available DNS servers to improve performance. However, if some servers have lower Priority than others, they will not be tried unless primary servers fail. This allows developers to implement high-performance and reliable send mail systems.

If both DnsServers and SmtpServers collections are non-empty, MailBee compares priorities of the highest-priority DNS server and the highest-priority SMTP relay server. If top prority SMTP server has the same or higher priority than top priority DNS server, MailBee will try to send mail using SMTP relay server first. If it fails, DNS MX lookup (direct send) will be used. Thus, it's possible to easily combine both "direct send" and "send to relay SMTP server" methods to improve reliability of send mail operation even further.

Note Note
Higher priority value is actually lower integer value. I.e. 0 is top priority while 999 is the lowest priority.
Caution note Caution
Direct send is often used by spammers. Thus, many mail services do not accept mail submissions from unknown hosts. It's recommended to perform direct sending from the domain which has at least one MX record assigned. In this case, the hosts with which the application is communicating will be able to verify the sender domain and accept the message submission request.
Examples

This sample adds two primary and one backup DNS server into DnsServers collection. The mail is then sent to 3 recipients.

If the primary DNS servers are fine, they both will be used to discover SMTP servers accepting mail for the recipients domains. If primary servers fail for some reason, the backup server will be tried as well. SMTP relay server is not used.

// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.SmtpMail;

// The actual code (put it into a method of your class)

Smtp mailer = new Smtp();

// Add primary servers (top priority). In this sample, they are in 
// the same LAN or intranet where the computer running MailBee is located.
mailer.DnsServers.Add("192.168.0.1", 0);
mailer.DnsServers.Add("192.168.0.2", 0);

// Add backup server (low priority). The server from another sub-network 
// (such as company ISP's DNS server) is used. Thus, even if LAN servers 
// fail, DNS MX lookup will still work.
mailer.DnsServers.Add("11.22.33.44", 10);

// Compose the message.
mailer.From.AsString = "user@host.com";
mailer.To.AsString = "abc@company.com, 123@anothercompany.com, xyz@website.com";
mailer.Subject = "Test message";
mailer.BodyPlainText = "The message text";

// Send it.
mailer.Send();
See Also