+1 vote

I'm the licensed user. Does Gmail not support TLS 1.2?

I have used the same code for years to connect to gmail. I am pretty certain, I had TLS 1.2 working for gmail, but in the last week, I have users who cannot connect with the following code.

imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12;
imap.Connect("imap.google.com", 993);
imap.StartTLS();

All the sudden, I am getting exception thrown at Imap.Connect():

Tried to read a line, but received ''.  

Why does this only happens with Imap.Connect()

What's changed? I'm using the standard gmail settings: imap.gmail.com, port 993

by

1 Answer

0 votes
 
Best answer

Gmail supports TLS 1.2, same as Mail.dll.

As far as I remember Gmail never supported explicit TLS/SSL (Connect + StartTLS), also you should not be using TLS/SSL port with Connect in such case.

Gmail supports implicit TLS/SSL - you need to use ConnectSSL (and a default port of 993), and don't use StartTLS:

using (Imap imap= new Imap())
{
    imap.SSLConfiguration.EnabledSslProtocols=SslProtocols.Tls12;
    imap.ConnectSSL("imap.gmail.com");

    // ...

    imap.Close();
}
by (301k points)
...