Sending e-mails using multiple SMTP servers
You can send messages via multiple SMTP servers for various reasons. First, to improve reliability (if the main server is down, sending may still succeed via the backup server). Another case would be increased performance when sending multiple e-mails.
The multiple SMTP servers are useful when the developer is unsure of reliability of the SMTP server he is going to use for sending e-mails (e.g. the server crashes sometimes). For instance, when using a single SMTP server to send a message, if this SMTP server crashes, MailBee is unable to send the message.
Otherwise, when using multiple SMTP servers, if one SMTP server crashes, MailBee attempts to use another SMTP server according to the priority of these servers. This means that a server having the highest priority is used instead of the crashed server.
Use SMTP.SmtpServers.Add method to add a new instance of SmtpServer object. There are five overloads of this method. The first overload allows adding the direct SmtpServer object as follows:
SmtpServer serv = new SmtpServer();
serv.Name = "mail.domain.com";
serv.AccountName = "john_doe";
serv.Password = "secret";
Dim serv As SmtpServer = New SmtpServer()
serv.Name = "mail.domain.com"
serv.AccountName = "john_doe"
serv.Password = "secret"
Besides that, you can specify the priority of SMTP server. The default priority is 0 (i.e. the highest) which means it will be tried first. The following code adds two SMTP servers with different priority levels to collection:
oMailer.SmtpServers.Add("127.0.0.1", 25, 1);
oMailer.SmtpServers.Add("smtp.company.com", 25, 2);
oMailer.SmtpServers.Add("127.0.0.1", 25, 1)
oMailer.SmtpServers.Add("smtp.company.com", 25, 2)
In case if you want to use multiple SMTP relay servers for increased sending performance, refer to Send bulk e-mail through two SMTP relay servers for increased throughput article in Developer's Guide.