In some situations it may not be possible to send mail directly to the server that accepts mail for a given domain. The two most common situations are corporate networks which have centralized servers that are responsible for delivering and forwarding messages, or an Internet Service Provider (ISP) which specifically blocks access to all mail servers other than their own. This is usually done as either a security measure or as a means to inhibit users from sending unsolicited commercial e-mail messages. If the standard SMTP port is being blocked, then any connection attempts will either fail immediately with an error that the server is unreachable, or the connection will simply time-out. In either case, a relay server must be specified in order to send e-mail messages.
A relay server is a system which will accept messages addressed to users which may be in a different domain, and will relay those messages to the appropriate server that does accept mail for the domain. The RelayServer property specifies the host name or address of the mail server that will be used by the class to deliver a message. If this property is not set, then the SendMessage method will perform the normal MX record queries and attempt to make a direct connection to each mail server. If the RelayServer property is set, then the class always establishes a connection to that server and does not perform any MX record queries. The RelayPort property can be used to specify an alternate port number on which the relay mail server is accepting connections. If this property is set to a value of zero, then the default port number will be used.
It is important to note that using a mail server as a relay without the permission of the organization or individual who owns that server may violate Acceptable Use Policies and/or Terms of Service agreements with your service provider. Systems which relay messages from anyone, regardless of whether the message is coming from a recognized domain, are called open relays. Because open relays are often used to send unsolicited e-mail, many administrators block mail that comes from one. It is recommended that users check with their network administrators or Internet service providers to determine if access to external mail servers is restricted and what is the acceptable use policy for relaying messages through their mail servers.