Requests the mail server to start TLS/SSL negotiation and protect the connection with security layer.
true if TLS/SSL negotiation succeeded and the connection is now secured with TLS/SSL layer; otherwise, false.
The developer must call Hello method prior to calling StartTls. Also, Hello method must be called again after StartTls since TLS/SSL negotiation resets the connection.
As alternative to calling StartTls method, the developer can ask MailBee to start TLS/SSL negotiation automatically by setting SslMode property value to OnConnect or UseStartTls.
Note Not all mail servers support TLS/SSL functionality.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample attempts to establish TLS/SSL connection with the SMTP server, logs in an account on this server and sends a mail message on success.
[C#] // 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(); mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret"); mailer.Connect(); mailer.Hello(); mailer.StartTls(); mailer.Hello(); mailer.Login(); mailer.From.Email = "jdoe@domain.com"; mailer.To.Add("kathy@company.com"); mailer.Subject = "Report"; mailer.BodyPlainText = "The report contents"; mailer.Send(); mailer.Disconnect();
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.SmtpMail ' The actual code (put it into a method of your class) Dim mailer As New Smtp mailer.SmtpServers.Add("mail.domain.com", "jdoe", "secret") mailer.Connect() mailer.Hello() mailer.StartTls() mailer.Hello() mailer.Login() mailer.From.Email = "jdoe@domain.com" mailer.To.Add("kathy@company.com") mailer.Subject = "Report" mailer.BodyPlainText = "The report contents" mailer.Send() mailer.Disconnect()
Smtp Class | MailBee.SmtpMail Namespace | SslMode | SslProtocol