0 votes

Today - after making no changes for years - an email function that uses Limilabs Mail library started failing with the error "Authenticate as SSL client failed. You might be connecting to non SSL port."

I am trying to connect to Amazon Web Services Simple Email Service using Port 587, which is their published port number for explicit SSL connections.

Here is my relevant code:

Dim MailServer As New Smtp()

Try
    If IsNull(SMTPport, "") <> "" AndAlso IsNumeric(SMTPport) Then
        Dim SmtpPortInteger As Integer = CInt(SMTPport)
        MailServer.Connect(MailServerName, SmtpPortInteger)
    Else
        MailServer.Connect(MailServerName)
    End If

    If SMTPenableSSL = "Y" Then
        MailServer.StartTLS()
    End If

    MailServer.UseBestLogin(SMTPuserID, SMTPpassword)

Catch ex As Exception
    Event_DT.Dispose()
    InitializationError("Error occurred while connecting to email server: " _
        & ex.Message)
    Exit Sub
End Try

I confirmed that SMTPport is set to "587" and SMTPenableSSL is set to "Y".

The code is hitting the catch block.

How can I get past this new error?

by

1 Answer

0 votes

You are able to connect to port 587, however you are not able to establish proper SSL/TLS connection.

Examine the exception's InnerException property.

Try using TLS 1.2:

Using smtp As New Smtp()
    smtp.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12

    smtp.ConnectSSL("smtp.example.com")

    smtp.UseBestLogin("user@example.com", "password")

    '...

    smtp.Close()
End Using

https://www.limilabs.com/blog/use-tls12-with-smtp

Turn on logging:
https://www.limilabs.com/blog/logging-in-mail-dll

by (297k points)
...