Menu

How To Detect Tls Support

If you need to know what is TLS please have a look on SSL VS TLS
[TOC]

How To Detect Tls Support

Firstly you need to establish a plain text tcp connection by calling of TestConnection() function in Smtp client (MimeMailer) and then check for SupportsTls, if it is true means server supports Tls Communications.

This function will connect to server in plain text mode, gets the supported commands and if finds the support of StartTls will issue it.

private bool IsTls(string host, string tlsPort, string user, string pass)
{
    var mailer = new MimeMailer(host, tlsPort, user, pass)
    {
            SslType = SslMode.Auto,
            AuthenticationMode = AuthenticationType.Base64
    };
        mailer.SendCompleted += compEvent;
        mailer.TestConnection();
        return mailer.SupportsTls;
 }
private void compEvent(object sender, AsyncCompletedEventArgs e)
    if (e.UserState != null)
            Console.Out.WriteLine(e.UserState.ToString());
    if (e.Error != null)
    {
            MessageBox.Show(e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    else if (!e.Cancelled)
    {
            MessageBox.Show("Send successfull!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}

Note: Do not forget that the SslType should be auto.
Note: AuthentificationType depends on your server.


Related

Wiki: Home
Wiki: How To Detect Ssl Type
Wiki: How to Detect if mail server is Tls or Ssl
Wiki: SSL VS TLS
Wiki: Send Mime Mails to Implicit Ssl Smtp Mail Servers

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.