Catalyst Internet Mail .NET

Mail Exchanges

When a message is delivered to a user, the InternetMail class must determine what mail server is responsible for accepting messages for that user. This is accomplished using the Domain Name Service (DNS), a protocol that is most commonly used to resolve host names such as www.microsoft.com into Internet addresses. This is typically accomplished by sending a request to a nameserver, a computer system that provides domain name services. In addition to resolving host names, nameservers can also provide information about those servers which are responsible for accepting mail for a given domain. There can be multiple servers which process mail for a domain with each server assigned a priority as part of their mail exchange (MX) record. If there is no mail exchange record for a domain, then the domain name itself is used.

The SendMessage method examines each recipient address and queries the nameserver for the domains which are responsible for accepting mail for users in that domain. If there are multiple mail servers, they are sorted in order of their listed priority. The class then attempts to establish a connection with the server and to deliver the message. If a connection cannot be established, the next mail exchange server is selected from the list. If the message cannot be delivered, then an error is generated and the next recipient is processed.

The ability to query a nameserver to determine the name of the server responsible for accepting mail for a given domain is handled internally by the class, and in most cases, is completely transparent. However, there may be situations in which a specific set of nameservers must be used, most commonly with corporate intranets. In this case, the NameServer property array can be used to control what nameservers are used to perform MX record queries. By default, this property contains the nameservers that were assigned to the local host. Changing these values changes the nameservers that are used. For example, if a company had two nameservers for their intranet with the IP addresses of 192.168.31.1 and 192.168.32.1, the class could be instructed to use those nameservers with the following statements:

InternetMail1.NameServer(0) = "192.168.31.1"
InternetMail1.NameServer(1) = "192.168.32.1"

Note that only Internet (IP) addresses may be assigned to the NameServer property array. Attempting to specify a domain name will result in an error. To restore the original default nameservers used by the control, either save their original value before modifying the NameServer property or call the Reset method.