2

I use TIdPOP3 a lot, and it works great, except for GMail accounts.

Somehow it never works. I tried different combinations and ports, with and without SSL, and it always returns different errors.

My most recent try was to create an 'app specific' password on Gmail, and trying to connect using this password, on port 995. This time it returns 'Connection Closed Gracefully'.

Resolving hostname pop.gmail.com.
Connecting to 172.217.192.108.
Connected.
Disconnected.
Connection Closed Gracefully.

I also tried this:

popb.Host := 'pop.gmail.com';
popb.username := 'myacount@gmail.com';
popb.password := 'mypassword';
popb.Port := 995;
popb.IOHandler := sslpop;
popb.UseTLS := utUseImplicitTLS;
with sslpop do
begin
  Destination := 'pop.gmail.com:995';
  Host := 'pop.gmail.com';
  Port := 995;
  DefaultPort := 0;
end;

In this last example, it returns this error:

Error connecting with SSL. error:00000006:lib(0):func(0):EVP lib

This specific account I'm trying to fetch has 2-step verification; does this make it impossible to use with Indy?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
delphirules
  • 6,443
  • 17
  • 59
  • 108
  • 1
    I think you need to enable POP/IMAP settings in GMail. Otherwise, you need to use OAuth2 authentication and REST API calls – John Kouraklis Feb 03 '21 at 12:02
  • @JohnKouraklis It was already enabled, my issue was other, as my answer shows. Thanks anyway ! – delphirules Feb 03 '21 at 12:55
  • 1
    I know for a fact that GMail's 'app specific password' feature works with Indy, because I've tested it many times. On a side note, DON'T set the `SSLIOHandler` properties you are setting, `Connect` handles them for you. – Remy Lebeau Feb 03 '21 at 15:48

1 Answers1

3

I could fix the issue by setting Ssloptions.Method := sslvSSLv23.

Here is the full working code :

    pop.Host := 'pop.gmail.com';
    pop.username := 'myemail@gmail.com';
    pop.password := 'mypassword';
    pop.Port := 995;
    pop.IOHandler := sslpop;
    pop.UseTLS := utUseImplicitTLS;
    with sslpop do
    begin
      Destination := 'pop.gmail.com:995';
      Ssloptions.Method := sslvSSLv23;
      Host := 'pop.gmail.com';
      Port := 995;
      DefaultPort := 0;
    end;
delphirules
  • 6,443
  • 17
  • 59
  • 108
  • 3
    I see that you've resolved it, but you can find additional info from Remy Lebeau on the following link: https://stackoverflow.com/questions/27261199/delphi-with-indy10-how-to-auto-negotiate-highest-tls-level-available where he's stating that `SSLOption.Method` shouldn't be used anymore and that `SSLOption.SSLVersions` property should be used instead. – Mark Feb 03 '21 at 14:54
  • 3
    Yes, do replace `SSSLOptions.Method := sslvSSLv23;` with `SSLOptions.SSLVersion := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];` instead – Remy Lebeau Feb 03 '21 at 15:52