Using MailKit with TLS with no certificates in VB.net

  • Thread starter Thread starter ElDourado
  • Start date Start date
E

ElDourado

Guest
I'm trying to change our code to send emails with MailKit since the old SMTPClient is obsolete.

We connect to our own server and don't need to authenticate. Here is the code:

Using client = New SmtpClient()
Dim values = SQL.EMAIL_SQL.GetSMTPInfo("MailHostOutsideNetwork")
client.Connect(values.Item1, values.Item2, Security.SecureSocketOptions.None)
client.Send(Message)
client.Disconnect(True)
End Using
GetSMTPInfo just gets the info about the server and port.
I have it working and sending emails as long as I don't use TLS or SSL. When I try to use either of them, I get the exception:

An error occurred while attempting to establish an SSL or TLS connection.
The server's SSL certificate could not be validated for the following reasons:
- The server certificate has the following errors:
- A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

So, my first idea was to contact our IT department and ask about the certificates. They told me we've never had any certificates and most likely never will (some licensing bullshit).
The problem is they still want us to use TLS when sending emails and my boss says that there must be a way to do that (which I basically answered with... well yeah if we had our system and certificates in order. She was not vey happy lol).

So, now I'm here asking you if there is any way of doing that. Sending emails using TLS with no certificates. Any ideas?

Continue reading...
 
Back
Top