SmtpSmtpServers Property |
Namespace: MailBee.SmtpMail
In order to send mail to an SMTP server, the developer must add it to SmtpServers collection first.
SmtpServers collection can contain multiple servers, which allows the developer to implement reliable send mail solution. In this case, SmtpServer having the highest priority (i.e. the lowest Priority value) will be tried first. If it fails, other servers will be tried accordingly their priority values.
SmtpServers collection can be used in cooperation with DnsServers collection. Depending which collection's top priority server has higher priority than another collection's top priority server, MailBee will either try to send to relay SMTP servers first and use direct send (through DNS MX lookup) if SMTP relay failed, or try to send in direct mode first, and use SMTP relay as a backup. This approach can be used if the application is mission-critical, and failures are not allowed.
// 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(); // Specify SMTP server to use, and enable SMTP authentication. mailer.SmtpServers.Add("smtp.company.com", "john.doe@company.com", "secret"); // Tune some settings of the server just added. mailer.SmtpServers[0].IgnoreLoginFailure = true; // Compose the message. mailer.Message.From.DisplayName = "John Doe"; mailer.Message.From.Email = "john.doe@company.com"; mailer.Message.To.Add("Bill Smith", "bill@i-am-bill-smith.com"); mailer.Subject = "Your order"; mailer.BodyPlainText = "Purchased item description"; // Send it. mailer.Send();